Esempio n. 1
0
    static void MPU_InitData(MSData data)
    {
        byte i;

        for (i = 0; i < 4; i++)
        {
            data.forLoopCounters[i] = 0xFFFF;
        }

        for (i = 0; i < NUM_CHANS; i++)
        {
            data.chanMaps[i] = i;
        }

        for (i = 0; i < data.controls.Length; i++)
        {
            data.controls[i].SetMembersTo(0xFF);   //memset(data->controls, 0xFF, sizeof(data->controls));
        }
        Array.Fill <byte>(data.noteOnChans, 0xFF); //memset(data->noteOnChans, 0xFF, sizeof(data->noteOnChans));

        data.delay              = 0;
        data.noteOnCount        = 0;
        data.globalVolume       = 0x5A; /* 90% */
        data.globalVolumeTarget = 0x5A; /* 90% */
        data.tempoError         = 0;
        data.tempoPercent       = 0x64; /* = 100 */
        data.tempoTarget        = 0x64; /* = 100 */
        data.beatCount          = 0;
        data.measureCount       = 0;
        data.timeNumerator      = 4;
        data.timeFraction       = 0x208D5;  /* 133333 */
        data.beatFraction       = 0x208D5;  /* 133333 */
        data.timePerBeat        = 0x7A1200; /* 8000000 */
    }
Esempio n. 2
0
    /*
     * XMIDI.ASM - reset_sequence
     */
    static void MPU_ResetSequence(MSData data)
    {
        byte chan;

        for (chan = 0; chan < NUM_CHANS; chan++)
        {
            if (data.controls[chan].sustain is not 0xFF and >= 64)
            {
                s_mpu_controls[chan].sustain = 0;
                /* Sustain Off */
                MPU_Send((byte)(0xB0 | chan), 64, 0);
            }

            if (data.controls[chan].chan_lock is not 0xFF and >= 64)
            {
                MPU_FlushChannel(chan);
                MPU_ReleaseChannel(data.chanMaps[chan]);    /* release_channel */
                data.chanMaps[chan] = chan;
            }

            if (data.controls[chan].chan_protect is not 0xFF and >= 64)
            {
                s_mpu_lockStatus[chan] &= 0xBF;
            }

            if (data.controls[chan].voice_protect is not 0xFF and >= 64)
            {
                MPU_Send((byte)(0xB0 | chan), 112, 0);                                                          /* 112 = VOICE_PROTECT */
            }
        }
    }
Esempio n. 3
0
        public SpectrumSource(string filepath)
        {
            MSDataList msdList = new MSDataList();

            if (!File.Exists(filepath) && !Directory.Exists(filepath)) // Some mass spec "files" are really directory structures
            {
                throw new FileNotFoundException("Filepath not found: " + filepath, filepath);
            }

            ReaderList.FullReaderList.read(filepath, msdList, GetReaderConfig());
            msDataFile = msdList[0];
            //msDataFile = new MSDataFile(filepath);
            sourceFilepath = filepath;

            // create dummy spectrum/chromatogram list to simplify logic
            msDataFile.run.spectrumList     = msDataFile.run.spectrumList ?? new SpectrumListSimple();
            msDataFile.run.chromatogramList = msDataFile.run.chromatogramList ?? new ChromatogramListSimple();

            setInputFileWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);

            /*setInputFileDelegate = new ParameterizedThreadStart( startSetInputFile );
             * Thread setInputFileThread = new Thread( setInputFileDelegate );
             *
             * setInputFileThread.Start( (object) filepath );*/
        }
Esempio n. 4
0
        public SpectrumSource(string filepath)
        {
            MSDataList msdList      = new MSDataList();
            var        readerConfig = new ReaderConfig
            {
                simAsSpectra = Program.SimAsSpectra,
                srmAsSpectra = Program.SrmAsSpectra
            };

            ReaderList.FullReaderList.read(filepath, msdList, readerConfig);
            msDataFile = msdList[0];
            //msDataFile = new MSDataFile(filepath);
            sourceFilepath = filepath;

            // create dummy spectrum/chromatogram list to simplify logic
            msDataFile.run.spectrumList     = msDataFile.run.spectrumList ?? new SpectrumListSimple();
            msDataFile.run.chromatogramList = msDataFile.run.chromatogramList ?? new ChromatogramListSimple();

            setInputFileWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);

            /*setInputFileDelegate = new ParameterizedThreadStart( startSetInputFile );
             * Thread setInputFileThread = new Thread( setInputFileDelegate );
             *
             * setInputFileThread.Start( (object) filepath );*/
        }
Esempio n. 5
0
        public string outputFilename(string inputFilename, MSData inputMsData)
        {
            string runId = inputMsData.run.id;


            // if necessary, adjust runId so it makes a suitable filename
            if (String.IsNullOrEmpty(runId))
                runId = Path.GetFileNameWithoutExtension(inputFilename) ?? string.Empty;
            else
            {
                string tempExtension = (Path.GetExtension(runId) ?? string.Empty).ToLower();
                if (tempExtension == ".mzml" ||
                    tempExtension == ".mzxml" ||
                    tempExtension == ".xml" ||
                    tempExtension == ".mgf" ||
                    tempExtension == ".ms2" ||
                    tempExtension == ".cms2")
                    runId = Path.GetFileNameWithoutExtension(runId) ?? string.Empty;
            }

            // this list is for Windows; it's a superset of the POSIX list
            const string illegalFilename = "\\/*:?<>|\"";
            foreach (var t in illegalFilename)
                if (runId.Contains(t))
                    runId = runId.Replace(t, '_');

            var newFilename = runId + Extension;
            var fullPath = Path.Combine(OutputPath, newFilename);
            return fullPath;
        }
Esempio n. 6
0
    static void MPU_StopAllNotes(MSData data)
    {
        byte i;

        for (i = 0; i < MAX_NOTES; i++)
        {
            byte note;
            byte chan;

            chan = data.noteOnChans[i];
            if (chan == 0xFF)
            {
                continue;
            }

            data.noteOnChans[i] = 0xFF;
            note = data.noteOnNotes[i];
            chan = data.chanMaps[chan];

            /* Note Off */
            MPU_Send((byte)(0x80 | chan), note, 0);
        }

        data.noteOnCount = 0;
    }
Esempio n. 7
0
        public SpectrumSource(string filepath)
        {
            MSDataList msdList = new MSDataList();

            ReaderList.FullReaderList.read(filepath, msdList);
            msDataFile = msdList[0];
            //msDataFile = new MSDataFile(filepath);
            sourceFilepath = filepath;
        }
Esempio n. 8
0
        private static Task <DocumentWrapper <T> > PlatformReadAsync <T>(string documentId, string partition, ReadOptions readOptions)
        {
            var taskCompletionSource = new TaskCompletionSource <DocumentWrapper <T> >();
            var msReadOptions        = readOptions.ToMSReadOptions();

            MSData.Read(documentId, new Class(typeof(MSDictionaryDocument)), partition, msReadOptions, resultDoc =>
            {
                ProcessResult(resultDoc, taskCompletionSource);
            });
            return(taskCompletionSource.Task);
        }
Esempio n. 9
0
        private static Task <DocumentWrapper <T> > PlatformReplaceAsync <T>(string documentId, T document, string partition, WriteOptions writeOptions)
        {
            var taskCompletionSource = new TaskCompletionSource <DocumentWrapper <T> >();
            var msWriteOptions       = writeOptions.ToMSWriteOptions();

            MSData.Replace(documentId, document.ToMSDocument(), partition, msWriteOptions, resultDoc =>
            {
                ProcessResult(resultDoc, taskCompletionSource);
            });
            return(taskCompletionSource.Task);
        }
Esempio n. 10
0
    internal static ushort MPU_SetData(/*byte[]*/ Span <byte> file, ushort index, MSData msdata)
    {
        var    data = msdata;
        uint   header;
        uint   size;
        ushort i;
        var    pointer = 0;

        if (file == null)
        {
            return(0xFFFF);
        }

        for (i = 0; i < 8; i++)
        {
            if (s_mpu_msdata[i] == null)
            {
                break;
            }
        }
        if (i == 8)
        {
            return(0xFFFF);
        }

        file = MPU_FindSoundStart(file, index);
        if (file == null)
        {
            return(0xFFFF);
        }

        s_mpu_msdata[i] = data;
        data.EVNT       = null;

        header = Read_BE_UInt32(file.Slice(pointer));
        size   = 12;
        while (header != SharpDune.MultiChar[FourCC.EVNT])
        {
            pointer += (int)size;
            header   = Read_BE_UInt32(file.Slice(pointer));
            size     = Read_BE_UInt32(file.Slice(pointer + 4)) + 8;
        }

        data.EVNT         = file.Slice(pointer).ToArray();
        data.playing      = 0;
        data.delayedClear = false;

        s_mpu_msdataSize++;

        MPU_InitData(data);

        return(i);
    }
Esempio n. 11
0
 static Data()
 {
     _remoteOperationDelegate.OnDataDidCompleteRemoteOperationAction = (operation, documentMetadata, error) =>
     {
         RemoteOperationCompleted?.Invoke(null, new RemoteOperationCompletedEventArgs
         {
             Operation        = operation,
             DocumentMetadata = documentMetadata.ToDocumentMetadata(),
             Error            = error?.ToDataException()
         });
     };
     MSData.SetRemoteOperationDelegate(_remoteOperationDelegate);
 }
Esempio n. 12
0
        protected void readVendorFile()
        {
            jobInfo.log("Prepare to Parse Vendor File", "Prepare");
            msd = new MSDataFile(jobInfo.inputFilePath);
            jobInfo.log("Adapting Vendor File API", "Adapting");

            List <string> filter = new List <string>();

            SpectrumListFactory.wrap(msd, filter); //这一步操作可以帮助加快Wiff文件的初始化速度

            spectrumList = msd.run.spectrumList;
            if (spectrumList == null || spectrumList.empty())
            {
                jobInfo.logError("No Spectrums Found");
            }
            else
            {
                jobInfo.log("Adapting Finished");
            }

            if (jobInfo.format.Equals("WIFF"))
            {
                FileInfo file1 = new FileInfo(jobInfo.inputFilePath);
                if (file1.Exists)
                {
                    fileSize += file1.Length;
                }

                FileInfo file2 = new FileInfo(jobInfo.inputFilePath + ".mtd");
                if (file2.Exists)
                {
                    fileSize += file2.Length;
                }

                FileInfo file3 = new FileInfo(jobInfo.inputFilePath + ".scan");
                if (file3.Exists)
                {
                    fileSize += file3.Length;
                }
            }

            if (jobInfo.format.Equals("RAW"))
            {
                FileInfo file1 = new FileInfo(jobInfo.inputFilePath);
                if (file1.Exists)
                {
                    fileSize += file1.Length;
                }
            }
        }
        public void MzMLIndexedReadTest(string inputFileRelativePath, int expectedSpectra)
        {
            if (!TestPath.FindInputFile(inputFileRelativePath, out var sourceFile))
            {
                Console.WriteLine("File not found: " + inputFileRelativePath);
                return;
            }

            var reader = new MzMLReader(Path.Combine(TestPath.ExtTestDataDirectory, sourceFile.FullName));
            //mzMLType mzMLData = reader.Read();
            var mzMLData = new MSData(reader.Read());

            Console.WriteLine("Spectrum count: " + mzMLData.Run.SpectrumList.Spectra.Count);
            Assert.AreEqual(expectedSpectra, mzMLData.Run.SpectrumList.Spectra.Count, "Spectrum count");
        }
Esempio n. 14
0
        public SpectrumSource(string filepath)
        {
            MSDataList msdList = new MSDataList();

            ReaderList.FullReaderList.read(filepath, msdList);
            msDataFile = msdList[0];
            //msDataFile = new MSDataFile(filepath);
            sourceFilepath = filepath;

            setInputFileWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);

            /*setInputFileDelegate = new ParameterizedThreadStart( startSetInputFile );
             * Thread setInputFileThread = new Thread( setInputFileDelegate );
             *
             * setInputFileThread.Start( (object) filepath );*/
        }
Esempio n. 15
0
        public string outputFilename(string inputFilename, MSData inputMsData)
        {
            string runId = inputMsData.run.id;

            try
            {
                // if necessary, adjust runId so it makes a suitable filename
                if (String.IsNullOrEmpty(runId))
                {
                    runId = Path.GetFileNameWithoutExtension(inputFilename) ?? string.Empty;
                }
                else
                {
                    string extension = (Path.GetExtension(runId) ?? string.Empty).ToLower();
                    if (extension == ".mzml" ||
                        extension == ".mzxml" ||
                        extension == ".xml" ||
                        extension == ".mgf" ||
                        extension == ".ms1" ||
                        extension == ".cms1" ||
                        extension == ".ms2" ||
                        extension == ".cms2" ||
                        extension == ".mz5")
                    {
                        runId = Path.GetFileNameWithoutExtension(runId) ?? string.Empty;
                    }
                }

                // this list is for Windows; it's a superset of the POSIX list
                const string illegalFilename = "\\/*:?<>|\"";
                foreach (var t in illegalFilename)
                {
                    if (runId.Contains(t))
                    {
                        runId = runId.Replace(t, '_');
                    }
                }

                var newFilename = runId + Extension;
                var fullPath    = Path.Combine(OutputPath, newFilename);
                return(fullPath);
            }
            catch (ArgumentException e)
            {
                throw new ArgumentException(String.Format("error generating output filename for input file '{0}' and output run id '{1}'", inputFilename, runId), e);
            }
        }
Esempio n. 16
0
        public void MzMLIndexedReadTest(string path, int expectedSpectra)
        {
            var sourceFile = new FileInfo(Path.Combine(TestPath.ExtTestDataDirectory, path));

            if (!sourceFile.Exists)
            {
                Console.WriteLine("File not found: " + sourceFile.FullName);
                return;
            }

            var reader = new MzMLReader(Path.Combine(TestPath.ExtTestDataDirectory, sourceFile.FullName));
            //mzMLType mzMLData = reader.Read();
            var mzMLData = new MSData(reader.Read());

            Console.WriteLine("Spectrum count: " + mzMLData.Run.SpectrumList.Spectra.Count);
            Assert.AreEqual(expectedSpectra, mzMLData.Run.SpectrumList.Spectra.Count, "Spectrum count");
        }
Esempio n. 17
0
        private static Task <PaginatedDocuments <T> > PlatformListAsync <T>(string partition, ReadOptions readOptions)
        {
            var taskCompletionSource = new TaskCompletionSource <PaginatedDocuments <T> >();

            MSData.List(new Class(typeof(MSDictionaryDocument)), partition, readOptions.ToMSReadOptions(), resultPages =>
            {
                if (resultPages.CurrentPage().Error == null)
                {
                    taskCompletionSource.SetResult(resultPages.ToPaginatedDocuments <T>());
                }
                else
                {
                    taskCompletionSource.SetException(resultPages.CurrentPage().Error.ToDataException());
                }
            });
            return(taskCompletionSource.Task);
        }
Esempio n. 18
0
        private static Task <DocumentWrapper <T> > PlatformCreateAsync <T>(string documentId, T document, string partition, WriteOptions writeOptions)
        {
            var taskCompletionSource = new TaskCompletionSource <DocumentWrapper <T> >();
            var msWriteOptions       = writeOptions.ToMSWriteOptions();

            try
            {
                var msDictionaryDocument = document.ToMSDocument();
                MSData.Create(documentId, msDictionaryDocument, partition, msWriteOptions, resultDoc =>
                {
                    ProcessResult(resultDoc, taskCompletionSource);
                });
            }
            catch (NSErrorException e)
            {
                taskCompletionSource.SetException(e);
            }
            return(taskCompletionSource.Task);
        }
Esempio n. 19
0
        //-------------------------------------------

        /// <summary>
        /// Just a plain simple way to join peaks that are very close together.
        /// This method is recomended to be used after deconvolution
        /// </summary>
        /// <param name="tolerance"></param>
        public void ClusterMSIons(double tolerance)
        {
            MSData.Sort((a, b) => a.MZ.CompareTo(b.MZ));
            bool needsToCluster  = true;
            int  externalCounter = 0;

            while (needsToCluster)
            {
                needsToCluster = false;
                List <Ion> ionsToExclude = new List <Ion>(MSData.Count);
                for (int i = externalCounter; i < MSData.Count; i++)
                {
                    double upperbound = MSData[i].MZ + tolerance;
                    for (int k = i; k < MSData.Count; k++)
                    {
                        if (i == k)
                        {
                            continue;
                        }
                        if (MSData[k].MZ > upperbound)
                        {
                            break;
                        }
                        externalCounter = i;

                        if (MSData[k].MZ <= upperbound)
                        {
                            ionsToExclude.Add(MSData[k]);
                        }
                    }
                }

                if (ionsToExclude.Count > 0)
                {
                    needsToCluster = true;
                    foreach (Ion i in ionsToExclude)
                    {
                        MSData.Remove(i);
                    }
                }
            }
        }
Esempio n. 20
0
        public string outputFilename(string inputFilename, MSData inputMsData)
        {
            string runId = inputMsData.run.id;


            // if necessary, adjust runId so it makes a suitable filename
            if (String.IsNullOrEmpty(runId))
            {
                runId = Path.GetFileNameWithoutExtension(inputFilename) ?? string.Empty;
            }
            else
            {
                string tempExtension = (Path.GetExtension(runId) ?? string.Empty).ToLower();
                if (tempExtension == ".mzml" ||
                    tempExtension == ".mzxml" ||
                    tempExtension == ".xml" ||
                    tempExtension == ".mgf" ||
                    tempExtension == ".ms2" ||
                    tempExtension == ".cms2")
                {
                    runId = Path.GetFileNameWithoutExtension(runId) ?? string.Empty;
                }
            }

            // this list is for Windows; it's a superset of the POSIX list
            const string illegalFilename = "\\/*:?<>|\"";

            foreach (var t in illegalFilename)
            {
                if (runId.Contains(t))
                {
                    runId = runId.Replace(t, '_');
                }
            }

            var newFilename = runId + Extension;
            var fullPath    = Path.Combine(OutputPath, newFilename);

            return(fullPath);
        }
Esempio n. 21
0
        public SpectrumSource(OpenDataSourceDialog.MSDataRunPath filepath)
        {
            if (!File.Exists(filepath.Filepath) && !Directory.Exists(filepath.Filepath)) // Some mass spec "files" are really directory structures
            {
                throw new FileNotFoundException("Filepath not found: " + filepath, filepath.Filepath);
            }

            MSDataFile = new MSData();
            ReaderList.FullReaderList.read(filepath.Filepath, MSDataFile, filepath.RunIndex, GetReaderConfig());
            sourceFilepath = filepath.ToString();

            // create dummy spectrum/chromatogram list to simplify logic
            MSDataFile.run.spectrumList     = MSDataFile.run.spectrumList ?? new SpectrumListSimple();
            MSDataFile.run.chromatogramList = MSDataFile.run.chromatogramList ?? new ChromatogramListSimple();

            setInputFileWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);

            /*setInputFileDelegate = new ParameterizedThreadStart( startSetInputFile );
             * Thread setInputFileThread = new Thread( setInputFileDelegate );
             *
             * setInputFileThread.Start( (object) filepath );*/
        }
Esempio n. 22
0
        public void MzMLWriteTest(string inPath, string outFolderName, int expectedSpectra)
        {
            var sourceFile = new FileInfo(Path.Combine(TestPath.ExtTestDataDirectory, inPath));

            if (!sourceFile.Exists)
            {
                Console.WriteLine("File not found: " + sourceFile.FullName);
                return;
            }

            if (sourceFile.DirectoryName == null)
            {
                throw new DirectoryNotFoundException("Cannot determine the parent folder of " + sourceFile.FullName);
            }

            var outFolder = new DirectoryInfo(Path.Combine(sourceFile.DirectoryName, outFolderName));

            if (!outFolder.Exists)
            {
                outFolder.Create();
            }

            var outFile = new FileInfo(Path.Combine(outFolder.FullName, sourceFile.Name));

            var reader   = new MzMLReader(Path.Combine(TestPath.ExtTestDataDirectory, inPath));
            var mzMLData = new MSData(reader.Read());

            Console.WriteLine("Array length: " + mzMLData.Run.SpectrumList.Spectra.Count);
            Assert.AreEqual(expectedSpectra, mzMLData.Run.SpectrumList.Spectra.Count, "Array length");

            var writer = new MzMLWriter(Path.Combine(TestPath.ExtTestDataDirectory, outFile.FullName))
            {
                MzMLType = MzMLSchemaType.MzML
            };

            writer.Write(new mzMLType(mzMLData));
        }
Esempio n. 23
0
        private static Task <PaginatedDocuments <T> > PlatformListAsync <T>(string partition)
        {
            var taskCompletionSource = new TaskCompletionSource <PaginatedDocuments <T> >();

            try
            {
                MSData.List(new Class(typeof(MSDictionaryDocument)), partition, resultPages =>
                {
                    if (resultPages.CurrentPage().Error == null)
                    {
                        taskCompletionSource.SetResult(resultPages.ToPaginatedDocuments <T>());
                    }
                    else
                    {
                        taskCompletionSource.SetException(resultPages.CurrentPage().Error.ToDataException());
                    }
                });
            }
            catch (JsonException e)
            {
                taskCompletionSource.SetException(new DataException("Failed to list data object(s)", e));
            }
            return(taskCompletionSource.Task);
        }
Esempio n. 24
0
		public SpectrumSource( string filepath )
		{
            MSDataList msdList = new MSDataList();
            var readerConfig = new ReaderConfig
            {
                simAsSpectra = Program.SimAsSpectra,
                srmAsSpectra = Program.SrmAsSpectra
            };
            ReaderList.FullReaderList.read(filepath, msdList, readerConfig);
            msDataFile = msdList[0];
			//msDataFile = new MSDataFile(filepath);
			sourceFilepath = filepath;

            // create dummy spectrum/chromatogram list to simplify logic
            msDataFile.run.spectrumList = msDataFile.run.spectrumList ?? new SpectrumListSimple();
            msDataFile.run.chromatogramList = msDataFile.run.chromatogramList ?? new ChromatogramListSimple();

			setInputFileWaitHandle = new EventWaitHandle( false, EventResetMode.ManualReset );
			/*setInputFileDelegate = new ParameterizedThreadStart( startSetInputFile );
			Thread setInputFileThread = new Thread( setInputFileDelegate );

			setInputFileThread.Start( (object) filepath );*/
		}
Esempio n. 25
0
 internal MSDataInternalTypeAbstract()
 {
     _msData = new MSData(false);
 }
Esempio n. 26
0
 public MsDataFileImpl(string path, int sampleIndex = 0, LockMassParameters lockmassParameters = null, bool simAsSpectra = false, bool srmAsSpectra = false, bool acceptZeroLengthSpectra = true, bool requireVendorCentroidedMS1 = false, bool requireVendorCentroidedMS2 = false)
 {
     // see note above on enabling performance measurement
     _perf = PerfUtilFactory.CreatePerfUtil("MsDataFileImpl " + // Not L10N 
         string.Format("{0},sampleIndex:{1},lockmassCorrection:{2},simAsSpectra:{3},srmAsSpectra:{4},acceptZeroLengthSpectra:{5},requireVendorCentroidedMS1:{6},requireVendorCentroidedMS2:{7}",  // Not L10N
         path, sampleIndex, !(lockmassParameters == null || lockmassParameters.IsEmpty), simAsSpectra, srmAsSpectra, acceptZeroLengthSpectra, requireVendorCentroidedMS1, requireVendorCentroidedMS2));
     using (_perf.CreateTimer("open")) // Not L10N
     {
         FilePath = path;
         _msDataFile = new MSData();
         _config = new ReaderConfig {simAsSpectra = simAsSpectra, srmAsSpectra = srmAsSpectra, acceptZeroLengthSpectra = acceptZeroLengthSpectra};
         _lockmassParameters = lockmassParameters;
         FULL_READER_LIST.read(path, _msDataFile, sampleIndex, _config);
         _requireVendorCentroidedMS1 = requireVendorCentroidedMS1;
         _requireVendorCentroidedMS2 = requireVendorCentroidedMS2;
     }
 }
        public void Open(string fileName, int sampleIndex)
        {
            if (_currentSampleIndex != sampleIndex || _currentFileName != fileName)
            {
                MSDataList msdList = new MSDataList();
                ReaderList.FullReaderList.read(fileName, msdList);
                _dataFile = msdList[0];
                _run = _dataFile.run;

                _currentFileName = fileName;
                _currentSampleIndex = sampleIndex;

                spectrumCache = new SpectrumCache();
                ticGenerator = new TicGenerator(_run, spectrumCache);
                xicGenerator = new XicGenerator(_run, spectrumCache);
                spectrumExtractor = new SpectrumExtractor(_run, spectrumCache);
                averagedSpectrumExtractor = new AveragedSpectrumExtractor(_run, spectrumCache);
            }
        }
Esempio n. 28
0
            public void populateFromMSData( MSData msInfo )
            {
                hasDetails = true;
                spectra = msInfo.run.spectrumList == null ? 0 : msInfo.run.spectrumList.size();
                ionSource = analyzer = detector = "";
                foreach( InstrumentConfiguration ic in msInfo.instrumentConfigurationList )
                {
                    SortedDictionary<int, string> ionSources = new SortedDictionary<int, string>();
                    SortedDictionary<int, string> analyzers = new SortedDictionary<int, string>();
                    SortedDictionary<int, string> detectors = new SortedDictionary<int, string>();
                    foreach( pwiz.CLI.msdata.Component c in ic.componentList )
                    {
                        CVParam term;
                        switch( c.type )
                        {
                            case ComponentType.ComponentType_Source:
                                term = c.cvParamChild( CVID.MS_ionization_type );
                                if( !term.empty() )
                                    ionSources.Add( c.order, term.name );
                                break;
                            case ComponentType.ComponentType_Analyzer:
                                term = c.cvParamChild( CVID.MS_mass_analyzer_type );
                                if( !term.empty() )
                                    analyzers.Add( c.order, term.name );
                                break;
                            case ComponentType.ComponentType_Detector:
                                term = c.cvParamChild( CVID.MS_detector_type );
                                if( !term.empty() )
                                    detectors.Add( c.order, term.name );
                                break;
                        }
                    }

                    if( ionSource.Length > 0 )
                        ionSource += ", ";
                    ionSource += String.Join( "/", new List<string>( ionSources.Values ).ToArray() );

                    if( analyzer.Length > 0 )
                        analyzer += ", ";
                    analyzer += String.Join( "/", new List<string>( analyzers.Values ).ToArray() );

                    if( detector.Length > 0 )
                        detector += ", ";
                    detector += String.Join( "/", new List<string>( detectors.Values ).ToArray() );
                }

                System.Collections.Generic.Set<string> contentTypes = new System.Collections.Generic.Set<string>();
                CVParamList cvParams = msInfo.fileDescription.fileContent.cvParams;
                if( cvParams.Count > 0 )
                {
                    foreach( CVParam term in msInfo.fileDescription.fileContent.cvParams )
                        contentTypes.Add( term.name );
                    contentType = String.Join( ", ", new List<string>( contentTypes.Keys ).ToArray() );
                }
            }
Esempio n. 29
0
        private void listView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            if (listView.SelectedItems.Count > 1)
            {
                List <string> dataSourceList = new List <string>();
                foreach (ListViewItem item in listView.SelectedItems)
                {
                    if (item.SubItems[1].Text != "File Folder")
                    {
                        dataSourceList.Add(String.Format("\"{0}\"", item.SubItems[0].Text));
                    }
                }
                sourcePathTextBox.Text = String.Join(" ", dataSourceList.ToArray());

                ticGraphControl.GraphPane.GraphObjList.Clear();
                ticGraphControl.GraphPane.CurveList.Clear();
                ticGraphControl.Visible = false;
            }
            else if (listView.SelectedItems.Count > 0)
            {
                sourcePathTextBox.Text = listView.SelectedItems[0].SubItems[0].Text;

                ticGraphControl.GraphPane.GraphObjList.Clear();
                ticGraphControl.GraphPane.CurveList.Clear();

                string sourcePath = Path.Combine(CurrentDirectory, sourcePathTextBox.Text);
                string sourceType = getSourceType(sourcePath);
                if (!String.IsNullOrEmpty(sourceType) &&
                    sourceType != "File Folder")
                {
                    using (MSData msd = new MSData())
                    {
                        ReaderList.FullReaderList.read(sourcePath, msd, 0, SpectrumSource.GetReaderConfig());
                        using (ChromatogramList cl = msd.run.chromatogramList)
                        {
                            if (cl != null && !cl.empty() && cl.find("TIC") != cl.size())
                            {
                                ticGraphControl.Visible = true;
                                pwiz.CLI.msdata.Chromatogram tic = cl.chromatogram(cl.find("TIC"), true);
                                Map <double, double>         sortedFullPointList = new Map <double, double>();
                                IList <double> timeList      = tic.binaryDataArrays[0].data;
                                IList <double> intensityList = tic.binaryDataArrays[1].data;
                                int            arrayLength   = timeList.Count;
                                for (int i = 0; i < arrayLength; ++i)
                                {
                                    sortedFullPointList[timeList[i]] = intensityList[i];
                                }
                                ZedGraph.PointPairList points = new ZedGraph.PointPairList(
                                    new List <double>(sortedFullPointList.Keys).ToArray(),
                                    new List <double>(sortedFullPointList.Values).ToArray());
                                ZedGraph.LineItem item = ticGraphControl.GraphPane.AddCurve("TIC", points, Color.Black, ZedGraph.SymbolType.None);
                                item.Line.IsAntiAlias = true;
                                ticGraphControl.AxisChange();
                                ticGraphControl.Refresh();
                            }
                            else
                            {
                                ticGraphControl.Visible = false;
                            }
                        }
                    }
                }
                else
                {
                    ticGraphControl.Visible = false;
                }
            }
            else
            {
                sourcePathTextBox.Text = "";
            }
        }
Esempio n. 30
0
 internal MSDataInternalTypeAbstract(MSData instance)
 {
     MsData = instance;
 }
 public void Dispose()
 {
     if (_dataFile != null)
     {
         _dataFile.Dispose();
         _dataFile = null;
         GC.SuppressFinalize(this);
     }
 }
Esempio n. 32
0
 public override void DataDidCompleteRemoteOperation(MSData data, string operation, MSDocumentMetadata documentMetadata, MSDataError error)
 {
     OnDataDidCompleteRemoteOperationAction.Invoke(operation, documentMetadata, error);
 }
Esempio n. 33
0
 private static Task <bool> PlatformIsEnabledAsync()
 {
     return(Task.FromResult(MSData.IsEnabled()));
 }
Esempio n. 34
0
        public SpectrumSource( string filepath )
        {
            MSDataList msdList = new MSDataList();
            ReaderList.FullReaderList.read( filepath, msdList );
            msDataFile = msdList[0];
            //msDataFile = new MSDataFile(filepath);
            sourceFilepath = filepath;

            setInputFileWaitHandle = new EventWaitHandle( false, EventResetMode.ManualReset );
            /*setInputFileDelegate = new ParameterizedThreadStart( startSetInputFile );
            Thread setInputFileThread = new Thread( setInputFileDelegate );

            setInputFileThread.Start( (object) filepath );*/
        }
Esempio n. 35
0
 private static Task PlatformSetEnabledAsync(bool enabled)
 {
     MSData.SetEnabled(enabled);
     return(Task.CompletedTask);
 }
Esempio n. 36
0
 private static void PlatformSetTokenExchangeUrl(string tokenExchangeUrl)
 {
     MSData.SetTokenExchangeUrl(tokenExchangeUrl);
 }
Esempio n. 37
0
            public void populateFromMSData(MSData msInfo)
            {
                hasDetails = true;
                spectra    = msInfo.run.spectrumList == null ? 0 : msInfo.run.spectrumList.size();
                ionSource  = analyzer = detector = "";
                foreach (InstrumentConfiguration ic in msInfo.instrumentConfigurationList)
                {
                    SortedDictionary <int, string> ionSources = new SortedDictionary <int, string>();
                    SortedDictionary <int, string> analyzers  = new SortedDictionary <int, string>();
                    SortedDictionary <int, string> detectors  = new SortedDictionary <int, string>();
                    foreach (pwiz.CLI.msdata.Component c in ic.componentList)
                    {
                        CVParam term;
                        switch (c.type)
                        {
                        case ComponentType.ComponentType_Source:
                            term = c.cvParamChild(CVID.MS_ionization_type);
                            if (!term.empty())
                            {
                                ionSources.Add(c.order, term.name);
                            }
                            break;

                        case ComponentType.ComponentType_Analyzer:
                            term = c.cvParamChild(CVID.MS_mass_analyzer_type);
                            if (!term.empty())
                            {
                                analyzers.Add(c.order, term.name);
                            }
                            break;

                        case ComponentType.ComponentType_Detector:
                            term = c.cvParamChild(CVID.MS_detector_type);
                            if (!term.empty())
                            {
                                detectors.Add(c.order, term.name);
                            }
                            break;
                        }
                    }

                    if (ionSource.Length > 0)
                    {
                        ionSource += ", ";
                    }
                    ionSource += String.Join("/", new List <string>(ionSources.Values).ToArray());

                    if (analyzer.Length > 0)
                    {
                        analyzer += ", ";
                    }
                    analyzer += String.Join("/", new List <string>(analyzers.Values).ToArray());

                    if (detector.Length > 0)
                    {
                        detector += ", ";
                    }
                    detector += String.Join("/", new List <string>(detectors.Values).ToArray());
                }

                System.Collections.Generic.Set <string> contentTypes = new System.Collections.Generic.Set <string>();
                CVParamList cvParams = msInfo.fileDescription.fileContent.cvParams;

                if (cvParams.Count > 0)
                {
                    foreach (CVParam term in msInfo.fileDescription.fileContent.cvParams)
                    {
                        contentTypes.Add(term.name);
                    }
                    contentType = String.Join(", ", new List <string>(contentTypes.Keys).ToArray());
                }
            }
Esempio n. 38
0
 public void Dispose()
 {
     if (_spectrumList != null)
         _spectrumList.Dispose();
     _spectrumList = null;
     if (_chromatogramList != null)
         _chromatogramList.Dispose();
     _chromatogramList = null;
     if (_msDataFile != null)
         _msDataFile.Dispose();
     _msDataFile = null;
 }