Пример #1
0
        /// <summary>
        /// Set peak ID
        /// </summary>
        /// <param name="dbData">DB data</param>
        /// <param name="item">File data item</param>
        /// <returns>error code</returns>
        private SIMCA_READ_ERR_CODE SetPeakId(SimcaDbData dbData, SimcaDataItem item)
        {
            if (this.DataType != SIMCA_DATA_TYPE.SCORE_PLOT)
            {
                item.PeakId = -1;
                if (this.HasRt && _secondaryIdIndexList.Count() >= 2)
                {
                    double rt, mz;
                    if (!item.TryGetDoubleValue(_secondaryIdIndexList[0], out rt))
                    {
                        return(SIMCA_READ_ERR_CODE.NG_FORMAT);
                    }
                    if (!item.TryGetDoubleValue(_secondaryIdIndexList[1], out mz))
                    {
                        return(SIMCA_READ_ERR_CODE.NG_FORMAT);
                    }
                    item.PeakId = dbData.FindPeakId(rt, mz);
                }
                else if (!this.HasRt && _secondaryIdIndexList.Count() >= 1)
                {
                    double mz;
                    if (!item.TryGetDoubleValue(_secondaryIdIndexList[0], out mz))
                    {
                        return(SIMCA_READ_ERR_CODE.NG_FORMAT);
                    }
                    item.PeakId = dbData.FindPeakId(mz);
                }
            }

            return(SIMCA_READ_ERR_CODE.OK);
        }
Пример #2
0
        /// <summary>
        /// Set score plot parameter
        /// </summary>
        /// <param name="dbData">DB data</param>
        /// <param name="item">File data item</param>
        /// <returns>T=Success F=Fail</returns>
        private SIMCA_READ_ERR_CODE SetScorePlotParam(SimcaDbData dbData, SimcaDataItem item)
        {
            if (this.DataType != SIMCA_DATA_TYPE.SCORE_PLOT)
            {   // type is different
                return(SIMCA_READ_ERR_CODE.OK);
            }

            item.Color     = Color.LightGreen;
            item.GroupId   = -1;
            item.SampleId  = -1;
            item.GroupName = string.Empty;

            // Get primary Id (string)
            string primaryId;

            if (!item.TryGetStrValue(PRIMARY_ID_INDEX, out primaryId))
            {
                return(SIMCA_READ_ERR_CODE.NG_FORMAT);
            }

            // Find sample name(sample name == primary Id)
            int groupIdx;
            int sampleIdx;

            if (dbData.FindSampleName(primaryId, out groupIdx, out sampleIdx))
            {
                item.Color     = dbData.GetGroupColor(groupIdx);
                item.GroupId   = dbData.GetGroupId(groupIdx);
                item.SampleId  = dbData.GetSampleId(groupIdx, sampleIdx);
                item.GroupName = dbData.GetGroupName(groupIdx);
            }

            return(SIMCA_READ_ERR_CODE.OK);
        }
Пример #3
0
        /// <summary>
        /// Check skip data
        /// </summary>
        /// <param name="dbData">DB data</param>
        /// <param name="item">File data item</param>
        /// <returns>error code</returns>
        private SIMCA_READ_ERR_CODE CheckSkipData(SimcaDbData dbData, SimcaDataItem item)
        {
            if (this.DataType == SIMCA_DATA_TYPE.SCORE_PLOT)
            {
                return(SIMCA_READ_ERR_CODE.OK);
            }

            double dummy;
            int    count = 0;

            foreach (int index in _secondaryIdIndexList)
            {
                if (!item.TryGetDoubleValue(index, out dummy))
                {
                    return(SIMCA_READ_ERR_CODE.SKIP);
                }

                count++;
                if (count >= 2)
                {
                    break;
                }
            }
            foreach (int index in _dataIndexList)
            {
                if (!item.TryGetDoubleValue(index, out dummy))
                {
                    return(SIMCA_READ_ERR_CODE.SKIP);
                }
                if (this.DataType == SIMCA_DATA_TYPE.S_PLOT)
                {
                    if (!item.TryGetDoubleValue(index + 1, out dummy))
                    {
                        return(SIMCA_READ_ERR_CODE.SKIP);
                    }
                }
            }
            return(SIMCA_READ_ERR_CODE.OK);
        }
Пример #4
0
        /// <summary>
        /// Add data(1 line)
        /// </summary>
        /// <param name="newData">1 line data</param>
        /// <param name="dbData">DB data</param>
        /// <returns>error code</returns>
        public SIMCA_READ_ERR_CODE Add(string[] newData, SimcaDbData dbData)
        {
            SIMCA_READ_ERR_CODE result = SIMCA_READ_ERR_CODE.OK;

            SimcaDataItem item = new SimcaDataItem();

            item.SetData(newData, Color.LightGreen, -1, -1);

            // Split line data
            if (newData == null)
            {
                return(SIMCA_READ_ERR_CODE.NG_FORMAT);
            }

            if (_simcaDataList.Count() == 0)
            {   // title line
                item.IsTitle = true;

                // Set column count
                this.ColumnCount = newData.Count();

                // Set index data
                result = SetIndexData(newData);
            }
            else
            {   // data line
                if (this.ColumnCount != newData.Count())
                {
                    result = SIMCA_READ_ERR_CODE.NG_FORMAT;
                }
                else
                {
                    // Check loading plot skip data
                    result = CheckSkipData(dbData, item);

                    // Set peak ID
                    if (result == SIMCA_READ_ERR_CODE.OK)
                    {
                        result = SetPeakId(dbData, item);
                    }

                    // Set score plot parameter
                    if (result == SIMCA_READ_ERR_CODE.OK)
                    {
                        result = SetScorePlotParam(dbData, item);
                    }
                }
            }

            if (result == SIMCA_READ_ERR_CODE.OK)
            {
                _simcaDataList.Add(item);
            }

            if (result == SIMCA_READ_ERR_CODE.SKIP)
            {
                result = SIMCA_READ_ERR_CODE.OK;
            }

            return(result);
        }