Exemple #1
0
        /// <summary>
        /// Configure and return the appropriate target filter
        /// </summary>
        /// <param name="tool"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static ITargetFilter Create(LcmsIdentificationTool tool, Options options)
        {
            ITargetFilter targetFilter = null;

            switch (tool)
            {
            case LcmsIdentificationTool.MsgfPlus:
                targetFilter = new MsgfPlusTargetFilter(options);
                break;

            case LcmsIdentificationTool.MZIdentML:
                targetFilter = new MsgfPlusTargetFilter(options);
                break;

            case LcmsIdentificationTool.Sequest:
                targetFilter = new SequestTargetFilter(options);
                break;

            case LcmsIdentificationTool.XTandem:
                targetFilter = new XTandemTargetFilter(options);
                break;

            case LcmsIdentificationTool.MSAlign:
                targetFilter = new MsAlignTargetFilter(options);
                break;
            }

            return(targetFilter);
        }
        /// <summary>
        /// Copies the exsting database.
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        private void Filter(MassTagDatabase database, ITargetFilter filter)
        {
            Dictionary <int, bool> targets = new Dictionary <int, bool>();

            foreach (ConsensusTarget averageTarget in database.ConsensusTargets)
            {
                /// Perform any filtering now...we allow the mass tag to pass if one of the targets is allowed to pass through...
                bool shouldFilter = true;
                foreach (Target target in averageTarget.Targets)
                {
                    if (!filter.ShouldFilter(target))
                    {
                        shouldFilter = false;
                        break;
                    }
                }

                // Here we update the map, so that if it was filtered above, then we mark it As such so we dont add the protein data
                if (!targets.ContainsKey(averageTarget.Id))
                {
                    targets.Add(averageTarget.Id, shouldFilter);
                }
                targets[averageTarget.Id] = shouldFilter;
                if (shouldFilter)
                {
                    continue;
                }

                m_massTags.Add(averageTarget);
            }
            AggregateProteins();
        }
Exemple #3
0
        /// <summary>
        /// Create an alignment filter
        /// </summary>
        /// <param name="tool">Format of input data</param>
        /// <param name="options">Options</param>
        /// <returns>Alignment filter</returns>
        public static ITargetFilter Create(LcmsIdentificationTool tool, Options options)
        {
            ITargetFilter alignmentFilter = null;

            switch (tool)
            {
                case LcmsIdentificationTool.MsgfPlus:
                    alignmentFilter = new MsgfPlusAlignmentFilter(options);
                    break;
                case LcmsIdentificationTool.MZIdentML:
                    alignmentFilter = new MsgfPlusAlignmentFilter(options);
                    break;
                case LcmsIdentificationTool.Sequest:
                    alignmentFilter = new SequestAlignmentFilter(options);
                    break;
                case LcmsIdentificationTool.XTandem:
                    alignmentFilter = new XTandemAlignmentFilter(options);
                    break;
                case LcmsIdentificationTool.MSAlign:
                    alignmentFilter = new MsAlignAlignmentFilter(options);
                    break;
            }

            return alignmentFilter;
        }
Exemple #4
0
        /// <summary>
        /// Creates a list of filters
        /// </summary>
        /// <returns></returns>
        public static ITargetFilter CreateFilters(SupportedTools tool, Options options)
        {
            ITargetFilter filter = null;

            switch (tool)
            {
            case SupportedTools.Sequest:
                filter = new BottomUpSequestTargetFilter(options);
                break;

            case SupportedTools.XTandem:
                filter = new BottomUpXTandemTargetFilter(options);
                break;

            case SupportedTools.MsgfPlus:
                filter = new BottomUpMsgfTargetFilter(options);
                break;

            case SupportedTools.NotSupported:
                break;

            default:
                break;
            }

            return(filter);
        }
 /// <summary>
 /// Copy constructor based on an existing database and a filtering mechanism.
 /// </summary>
 /// <param name="database"></param>
 /// <param name="filter"></param>
 public MassTagDatabase(MassTagDatabase database, ITargetFilter filter)
 {
     MetaData     = new List <Analysis>();
     m_massTags   = new List <ConsensusTarget>();
     m_massTagMap = new Dictionary <string, ConsensusTarget>();
     Proteins     = new List <Protein>();
     Filter(database, filter);
 }
        void IPipeSpecification <TContext> .Apply(IPipeBuilder <TContext> builder)
        {
            IPipe <BindContext <TContext, TTarget> > pipe = _pipeConfigurator.Build();

            ITargetFilter <TTarget> targetFilter = _filterFactory();

            var bindFilter = new BindFilter <TContext, TTarget>(pipe, targetFilter);

            builder.AddFilter(bindFilter);
        }
        /// <summary>
        /// Filters a list of targets
        /// </summary>
        /// <param name="targets"></param>
        /// <returns></returns>
        private List <Target> FilterTargets(ITargetFilter filter, List <Target> targets)
        {
            List <Target> newTargets = new List <Target>();

            foreach (Target t in targets)
            {
                bool shouldFilter = filter.ShouldFilter(t);
                if (!shouldFilter)
                {
                    newTargets.Add(t);
                }
            }
            return(newTargets);
        }
Exemple #8
0
    public AttackInfo(IReach reach = null, IEffect effect = null, ITargetFilter filter = null, IAnimation animation = null)
    {
        this.Reach      = reach;
        this.Effect     = effect;
        this.Filter     = filter;
        AttackAnimation = animation;

        if (reach == null)
        {
            this.Reach = new Melee();
        }
        if (effect == null)
        {
            this.Effect = new Damage();
        }
        if (filter == null)
        {
            this.Filter = new TargetEnemy();
        }
        if (animation == null)
        {
            AttackAnimation = new Tackle();
        }
    }
Exemple #9
0
        /// <summary>
        /// Filters targets organized through the PHRP reader
        /// </summary>
        /// <param name="targets"></param>
        /// <param name="filter"></param>
        /// <returns></returns>
        protected List <Target> FilterTargets(List <Target> targets, ITargetFilter filter)
        {
            // Map the sequences first for each target
            //TODO: Convert to LINQ maybe...O(N) here, then O(lgN) -> O(N + lgN)
            Dictionary <string, List <Target> > xmap = new Dictionary <string, List <Target> >();

            foreach (Target target in targets)
            {
                if (!xmap.ContainsKey(target.Sequence))
                {
                    xmap.Add(target.Sequence, new List <Target>());
                }
                xmap[target.Sequence].Add(target);
            }

            List <Target> filteredTargets = new List <Target>();

            foreach (string key in xmap.Keys)
            {
                // Find the first occurrence.
                List <Target> xTargets = xmap[key];
                xTargets.Sort(delegate(Target x, Target y)
                {
                    return(y.Scan.CompareTo(x.Scan));
                });

                // Then make sure it passes the filters
                Target targetOfInterest = xTargets[0];
                if (!filter.ShouldFilter(targetOfInterest))
                {
                    filteredTargets.Add(targetOfInterest);
                }
            }

            return(filteredTargets);
        }
Exemple #10
0
        public static ITargetFilter FromJsonProperty(JObject jsonObject, string propertyName, ITargetFilter defaultValue = null)
        {
            //IL_0011: Unknown result type (might be due to invalid IL or missing references)
            //IL_0018: Invalid comparison between Unknown and I4
            JProperty val = jsonObject.Property(propertyName);

            if (val == null || (int)val.get_Value().get_Type() == 10)
            {
                return(defaultValue);
            }
            return(FromJsonToken(val.get_Value()));
        }
Exemple #11
0
 public BindFilter(IPipe <BindContext <T, TTarget> > output, ITargetFilter <TTarget> targetFilter)
 {
     _output       = output;
     _targetFilter = targetFilter;
 }
Exemple #12
0
 public DealDamageToTargetEffect(int amount, ITargetFilter filter)
     : this(amount)
 {
     Filter = filter;
 }
        private void ProcessAnalysisJobInternal(Analysis analysis, Options options, IRetentionTimePredictor predictor)
        {
            analysis.ProcessedState = ProcessingState.Processing;
            if (this.ProcessingAnalysis != null)
            {
                ProcessingAnalysis(this, new AnalysisCompletedEventArgs(1, 1, analysis));
            }

            IAnalysisReader reader = SequenceAnalysisToolsFactory.CreateReader(analysis.Tool);
            ITargetFilter   filter = TargetFilterFactory.CreateFilters(analysis.Tool, options);

            IRegressionAlgorithm regressor = RegressorFactory.CreateRegressor(RegressorType.LcmsRegressor, options.Regression);
            Analysis             results   = reader.Read(analysis.FilePath, analysis.Name);


            List <Target> targets = new List <Target>();
            Dictionary <string, Protein> proteins = new Dictionary <string, Protein>();

            foreach (var target in results.Targets)
            {
                if (options.ShouldFilter(target))
                {
                    continue;
                }

                targets.Add(target);

                foreach (var protein in target.Proteins)
                {
                    if (!proteins.ContainsKey(protein.Reference))
                    {
                        analysis.Proteins.Add(protein);
                        proteins.Add(protein.Reference, protein);
                    }
                }
            }
            analysis.AddTargets(targets);

            // Calculate the regression based on the target data
            List <float> predicted = new List <float>();
            List <float> scans     = new List <float>();

            int maxScan = 0;
            int minScan = 0;



            foreach (Target target in analysis.Targets)
            {
                // Filter the target here...based on use for alignment.
                if (filter.ShouldFilter(target))
                {
                    continue;
                }

                maxScan = Math.Max(maxScan, target.Scan);
                minScan = Math.Min(minScan, target.Scan);

                target.IsPredicted  = true;
                target.NetPredicted = predictor.GetElutionTime(target.CleanSequence);
                scans.Add(target.Scan);
                predicted.Add(Convert.ToSingle(target.NetPredicted));
            }
            analysis.RegressionResults = regressor.CalculateRegression(scans, predicted);
            //analysis.RegressionResults.Regressor = regressor;

            analysis.RegressionResults.MinScan = minScan;
            analysis.RegressionResults.MaxScan = maxScan;

            // Make the regression line data.
            int scan  = 0;
            int delta = 5;

            while (scan <= maxScan)
            {
                double y = regressor.GetTransformedNET(scan);
                scan += delta;

                analysis.RegressionResults.XValues.Add(Convert.ToDouble(scan));
                analysis.RegressionResults.YValues.Add(y);
            }


            // Then make sure we align all against the predicted self
            regressor.ApplyTransformation(analysis.Targets);

            analysis.ProcessedState = ProcessingState.Processed;
        }