示例#1
0
        public static IFilterLine Construct <T>(this ILineStrategy me, string ident, List <LineToken> tokens) where T : ILineValueCore, new()
        {
            var line = new FilterLine <T>()
            {
                Ident = ident,
                Value = new T()
            };

            line.Value.Parse(tokens);
            return(line);
        }
示例#2
0
        public static void FLineBasicTest()
        {
            var line = new FilterLine("Show");

            line.Init();
            Assert.AreEqual(EntryDataType.Rule, line.LineType);

            line = new FilterLine("Rarity Rare");
            line.Init();
            Assert.AreEqual(EntryDataType.Rule, line.LineType);

            line = new FilterLine("\t Class  Currency");
            line.Init();
            Assert.AreEqual(EntryDataType.Rule, line.LineType);
        }
        private string FixFilterLine()
        {
            // split FilterLine by spaces. remove empty entries
            var filterLineParts = FilterLine.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();

            for (var i = 0; i < filterLineParts.Count; i++)
            {
                var item = filterLineParts[i];
                if (item.Contains("cv="))
                {
                    filterLineParts.RemoveAt(i);
                    i--;
                }
            }

            return(string.Join(" ", filterLineParts.ToArray()));
        }
        private string GetScanType()
        {
            const string returnString = "Unknown";

            foreach (var param in FilterLine.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (param.Equals("Full"))
                {
                    return("Full");
                }

                if (param.Equals("SIM"))
                {
                    return("SIM");
                }
            }

            return(returnString);
        }
示例#5
0
        private FilterLine ProcessLine(string line)
        {
            FilterLine data = new FilterLine();

            switch (line[0])
            {
            case '-':
                data.OpenMethod = LineKind.Exclude;
                break;

            case '+':
                data.OpenMethod = LineKind.Include;
                break;

            default:
                data.OpenMethod = LineKind.None;
                break;
            }
            data.Expression = ProcessEscapingAnchors(line.Substring(1, line.Length - 1));
            return(data);
        }
 void WriteFilterLine(FilterLine filter)
 {
     WriteVerbose($"filter: {filter.Pattern.ToRegex()} -> {filter.Replacement}");
 }
示例#7
0
        public static IFilterLine GenerateFilterLine(List <LineToken> tokens)
        {
            FilterLineIdentPhase phase = FilterLineIdentPhase.IdentScan;

            IFilterLine result;

            string           ident          = string.Empty;
            bool             identCommented = false;
            List <LineToken> value          = new List <LineToken>();
            string           comment        = string.Empty;

            foreach (var token in tokens)
            {
                switch (phase)
                {
                case FilterLineIdentPhase.IdentScan:
                {
                    if (token.isIdent)
                    {
                        ident = token.value;

                        if (token.isCommented)
                        {
                            identCommented = true;
                        }
                    }
                    else
                    {
                        comment = token.value;
                        if (tokens.Count > 1)
                        {
                            comment += " ";
                        }
                    }

                    phase = FilterLineIdentPhase.ValueScan;
                }
                break;

                case FilterLineIdentPhase.ValueScan:
                {
                    if (token.isFluffComment == true)
                    {
                        comment += token.value;
                    }
                    else
                    {
                        value.Add(token);
                    }
                }
                break;
                }
            }

            if (ident != string.Empty)
            {
                result = FilterConstants.LineTypes[ident].Construct(ident, value);
            }
            else
            {
                result = new FilterLine <EmptyValueContainer>();
            }

            result.Comment        = comment;
            result.identCommented = identCommented;
            return(result);
        }
示例#8
0
        public void AddMs2ScanParameters(XRawFileIO reader)
        {
            // grab precursorMz from raw file
            var success = reader.GetScanInfo(ScanNumber, out var scanInfo);

            if (!success)
            {
                ConsoleMsgUtils.ShowWarning("Scan {0} not found by AddMs2ScanParameters", ScanNumber);
                return;
            }

            var precursorMzValue = Math.Round(scanInfo.ParentIonMZ, 8);

            var parentScanInfo = GetParentScan(reader, scanInfo);

            var parentScanDataCount = reader.GetScanData(parentScanInfo.ScanNumber, out var mzList, out var intensityList);

            double precursorIntensity = 0;

            if (parentScanDataCount > 0)
            {
                const double PRECURSOR_TOLERANCE = 0.1;

                var closestDifference = double.MaxValue;
                for (var i = 0; i < mzList.Length; i++)
                {
                    var mzDifference = Math.Abs(mzList[i] - precursorMzValue);
                    if (mzDifference > closestDifference)
                    {
                        continue;
                    }

                    closestDifference  = mzDifference;
                    precursorIntensity = Math.Round(intensityList[i], 2);
                }

                if (closestDifference > PRECURSOR_TOLERANCE)
                {
                    // couldn't find precursor mass in MS1. That's fine i guess.
                    precursorIntensity = 0;
                }
            }

            var filterLineParts = FilterLine.Split(' ');

            string activationType;

            switch (scanInfo.ActivationType)
            {
            case ActivationTypeConstants.CID:
            case ActivationTypeConstants.MPD:
            case ActivationTypeConstants.ECD:
            case ActivationTypeConstants.PQD:
            case ActivationTypeConstants.ETD:
            case ActivationTypeConstants.HCD:
            case ActivationTypeConstants.SA:
            case ActivationTypeConstants.PTR:
            case ActivationTypeConstants.NETD:
            case ActivationTypeConstants.NPTR:
            case ActivationTypeConstants.UVPD:
                activationType = scanInfo.ActivationType.ToString();
                break;

            default:
                // Includes ActivationTypeConstants.AnyType
                activationType = "CID";
                break;
            }

            foreach (var param in filterLineParts)
            {
                if (param.Contains("@"))
                {
                    // HCD25.00 -> [HCD, 25.00]
                    // RegEx alpha from numeric
                    var activationArray = Regex.Matches(param.Split('@')[1].Trim(), @"\D+|\d+").Cast <Match>().Select(m => m.Value).ToArray();

                    CollisionEnergy = Convert.ToInt32(double.Parse(activationArray[1]));
                }
            }

            PrecursorMz = new PrecursorMz(precursorIntensity, activationType, precursorMzValue);
        }