Ejemplo n.º 1
0
        /// <summary>
        /// Returns a LibraryRankedSpectrumInfo
        /// </summary>
        /// <param name="info">The spectrum to be ranked</param>
        /// <param name="labelType">The IsotopeLabelType for the peptide in the library. This might be different from the
        /// LabelType on the GroupDocNode.</param>
        /// <param name="groupDocNode">The Transition Group from the user's document</param>
        /// <param name="settings"></param>
        /// <param name="lookupSequence"></param>
        /// <param name="lookupMods"></param>
        /// <param name="charges">The set of charges that the user is choosing to show in the spectrum viewer.</param>
        /// <param name="types">The set of ion types to be displayed</param>
        /// <param name="rankCharges">The set of charges that are enabled in the document's Transition Settings</param>
        /// <param name="rankTypes">The set of ion types in the user's transition settings</param>
        /// <param name="score">the score to assign to the spectrum. If it is null, then the spectrum gets the score from transition group's LibInfo</param>
        /// <param name="useFilter">true if this list is being generated in order to show the filtered list of potential transitions</param>
        /// <param name="matchAll">true if peaks matched peaks should be given a list of all of the ion types that they match, instead
        /// of only being annotated with the first matching one</param>
        /// <param name="minPeaks">The minimum number of peaks to match, or -1 to match as many as possible</param>
        /// <returns></returns>
        public static LibraryRankedSpectrumInfo RankSpectrum(SpectrumPeaksInfo info,
                                                             IsotopeLabelType labelType,
                                                             TransitionGroupDocNode groupDocNode, SrmSettings settings,
                                                             Target lookupSequence, ExplicitMods lookupMods,
                                                             IEnumerable <Adduct> charges, IEnumerable <IonType> types,
                                                             IEnumerable <Adduct> rankCharges, IEnumerable <IonType> rankTypes,
                                                             double?score, bool useFilter, bool matchAll, int minPeaks)
        {
            var targetInfo     = new TargetInfo(labelType, groupDocNode, lookupSequence, lookupMods);
            var fragmentFilter = new FragmentFilter(settings.TransitionSettings, rankCharges, rankTypes).ChangeMatchAll(matchAll);

            if (!useFilter)
            {
                bool isProteomic = groupDocNode.TransitionGroup.IsProteomic;
                fragmentFilter = fragmentFilter.ChangeUseFilter(false);
                fragmentFilter = fragmentFilter
                                 .ChangeAdductsToDisplay(charges ?? GetRanked(fragmentFilter.RankedAdducts,
                                                                              isProteomic
                                                    ? Transition.DEFAULT_PEPTIDE_CHARGES
                                                    : Transition.DEFAULT_MOLECULE_CHARGES));
                fragmentFilter = fragmentFilter.ChangeIonTypesToDisplay(
                    types ?? GetRanked(fragmentFilter.RankedIonTypes,
                                       isProteomic ? Transition.PEPTIDE_ION_TYPES : Transition.MOLECULE_ION_TYPES));
                fragmentFilter = fragmentFilter.ChangeMatchAll(true);
            }
            else
            {
                if (null != charges)
                {
                    fragmentFilter = fragmentFilter.ChangeAdductsToDisplay(charges);
                }

                if (null != types)
                {
                    fragmentFilter = fragmentFilter.ChangeIonTypesToDisplay(types);
                }
            }
            bool limitRanks =
                groupDocNode.IsCustomIon && // For small molecules, cap the number of ranked ions displayed if we don't have any peak metadata
                groupDocNode.Transitions.Any(t => string.IsNullOrEmpty(t.FragmentIonName));

            if (limitRanks)
            {
                fragmentFilter = fragmentFilter.ChangeRankLimit(settings.TransitionSettings.Libraries.IonCount);
            }
            // If no library filtering will happen, return all rankings for view in the UI
            if (!useFilter || fragmentFilter.LibraryPick == TransitionLibraryPick.none)
            {
                if (fragmentFilter.LibraryPick == TransitionLibraryPick.none)
                {
                    fragmentFilter = fragmentFilter.ChangeLibraryPick(TransitionLibraryPick.all);
                }
                fragmentFilter = fragmentFilter.ChangeFragmentMatchCount(null);
            }

            var spectrumRanker = new SpectrumRanker(targetInfo, settings, fragmentFilter);

            return(spectrumRanker.RankSpectrum(info, minPeaks, score));
        }
Ejemplo n.º 2
0
        private void Render(DisplayObject obj, Matrix2D matrix = null, float alpha = 1.0f)
        {
            Painter        painter         = SparrowSharp.Painter;
            RenderState    state           = painter.State;
            bool           wasCacheEnabled = painter.CacheEnabled;
            FragmentFilter filter          = obj.Filter;
            DisplayObject  mask            = obj.Mask;

            painter.CacheEnabled = false;
            painter.PushState();

            state.Alpha = obj.Alpha * alpha;
            state.SetModelviewMatricesToIdentity();
            state.BlendMode = obj.BlendMode == BlendMode.AUTO ?
                              BlendMode.NORMAL : obj.BlendMode;

            if (matrix != null)
            {
                state.TransformModelviewMatrix(matrix);
            }
            else
            {
                state.TransformModelviewMatrix(obj.TransformationMatrix);
            }

            // OpenGL calculates y coordinates from the bottom, invert them here
            state.ModelviewMatrix.Scale(1, -1);
            state.ModelviewMatrix.Translate(0, Height);


            if (mask != null)
            {
                painter.DrawMask(mask);
            }

            if (filter != null)
            {
                filter.Render(painter);
            }
            else
            {
                obj.Render(painter);
            }

            if (mask != null)
            {
                painter.EraseMask(mask);
            }

            painter.PopState();
            painter.CacheEnabled = wasCacheEnabled;
        }
Ejemplo n.º 3
0
        public void render3d(Project project, SceneManager sceneMgr)
        {
            SharpMap.Map myMap = new SharpMap.Map();

            foreach (BuildLayer layer in project.getLayers())
            {
                Source source = layer.getSource();

                BoundingBox    envelope = new BoundingBox(-1000.0, -1000.0, 1000.0, 1000.0);//TODO
                FeatureDataSet ds       = new FeatureDataSet();
                source.DataSource.Open();
                source.DataSource.ExecuteIntersectionQuery(envelope, ds);
                source.DataSource.Close();

                FeatureDataTable features = (FeatureDataTable)ds.Tables[0];

                //El codigo del PFC

                //**********************************************************************************************************

                //Show map

                //Filters
                FilterGraph graph = project.getFilterGraph(source.getName());
                if (graph != null)
                {
                    graph.Successors();

                    FilterEnv   env  = new FilterEnv(sceneMgr, source.getName());
                    FeatureList list = Feature.DataTableToList(features);

                    if (graph.getFilter(1) is FeatureFilter)
                    {
                        FeatureFilter filter = (FeatureFilter)graph.getFilter(1);
                        FeatureList   l      = filter.process(list, env);
                    }
                    else if (graph.getFilter(1) is FragmentFilter)
                    {
                        FragmentFilter filter = (FragmentFilter)graph.getFilter(1);
                        FragmentList   l      = filter.process(list, env);
                    }
                }

                //**********************************************************************************************************
            }
        }
 protected bool IsStateChange(uint texture,
                              TextureSmoothing smoothing, string blendMode, FragmentFilter filter,
                              bool premultiplyAlpha, int numParticles)
 {
     if (_mNumParticles == 0)
     {
         return(false);
     }
     if (_mNumParticles + numParticles > MaxPossibleParticles)
     {
         return(true);
     }
     if (_mTexture != null && texture != 0)
     {
         return(_mTexture.Base != texture || TexSmoothing != smoothing || BlendMode != blendMode ||
                _mFilter != filter || PremultiplyAlpha != premultiplyAlpha);
     }
     return(true);
 }
 public FragmentFilterState(FragmentFilter _filter)
 {
     filter = _filter;
 }
Ejemplo n.º 6
0
        public SpectrumRanker(TargetInfo targetInfo, SrmSettings settings,
                              FragmentFilter fragmentFilter)
        {
            TargetInfoObj     = targetInfo;
            FragmentFilterObj = fragmentFilter;
            var             groupDocNode = TargetInfoObj.TransitionGroupDocNode;
            TransitionGroup group        = groupDocNode.TransitionGroup;
            bool            isProteomic  = group.IsProteomic;

            bool limitRanks =
                groupDocNode.IsCustomIon && // For small molecules, cap the number of ranked ions displayed if we don't have any peak metadata
                groupDocNode.Transitions.Any(t => string.IsNullOrEmpty(t.FragmentIonName));

            RankLimit = limitRanks ? settings.TransitionSettings.Libraries.IonCount : (int?)null;

            // Get necessary mass calculators and masses
            var            labelType    = targetInfo.SpectrumLabelType;
            var            lookupMods   = targetInfo.LookupMods;
            var            calcMatchPre = settings.GetPrecursorCalc(labelType, lookupMods);
            var            calcMatch    = isProteomic ? settings.GetFragmentCalc(labelType, lookupMods) : settings.GetDefaultFragmentCalc();
            var            calcPredict  = isProteomic ? settings.GetFragmentCalc(group.LabelType, lookupMods) : calcMatch;
            MoleculeMasses moleculeMasses;

            if (null != lookupMods && lookupMods.HasCrosslinks)
            {
                moleculeMasses = GetCrosslinkMasses(settings);
            }
            else
            {
                if (isProteomic && Sequence.IsProteomic)
                {
                    moleculeMasses = new MoleculeMasses(
                        SequenceMassCalc.GetMZ(calcMatchPre.GetPrecursorMass(Sequence), PrecursorAdduct),
                        new IonMasses(calcMatch.GetPrecursorFragmentMass(Sequence),
                                      calcMatch.GetFragmentIonMasses(Sequence)));
                }
                else if (!isProteomic && !Sequence.IsProteomic)
                {
                    string isotopicFormula;
                    var    knownFragments = new List <MatchedFragmentIon>();
                    foreach (var tran in groupDocNode.Transitions)
                    {
                        if (tran.Transition.IsNonPrecursorNonReporterCustomIon())
                        {
                            knownFragments.Add(new MatchedFragmentIon(IonType.custom, knownFragments.Count + 1,
                                                                      tran.Transition.Adduct,
                                                                      tran.GetFragmentIonName(CultureInfo.CurrentCulture,
                                                                                              settings.TransitionSettings.Libraries.IonMatchTolerance),
                                                                      null,
                                                                      tran.Mz));
                        }
                    }

                    var ionMasses =
                        new IonMasses(calcMatch.GetPrecursorFragmentMass(Sequence), IonTable <TypedMass> .EMPTY)
                        .ChangeKnownFragments(knownFragments);
                    moleculeMasses =
                        new MoleculeMasses(
                            SequenceMassCalc.GetMZ(
                                calcMatchPre.GetPrecursorMass(Sequence.Molecule, null, PrecursorAdduct,
                                                              out isotopicFormula), PrecursorAdduct), ionMasses);
                }
                else
                {
                    moleculeMasses = new MoleculeMasses(0.0,
                                                        new IonMasses(TypedMass.ZERO_MONO_MASSH, IonTable <TypedMass> .EMPTY));
                }

                if (!ReferenceEquals(calcPredict, calcMatch))
                {
                    var ionTable = moleculeMasses.MatchIonMasses.FragmentMasses;
                    if (Sequence.IsProteomic
                        ) // CONSIDER - eventually we may be able to predict fragments for small molecules?
                    {
                        ionTable = calcPredict.GetFragmentIonMasses(Sequence);
                    }
                    moleculeMasses =
                        moleculeMasses.ChangePredictIonMasses(new IonMasses(
                                                                  calcPredict.GetPrecursorFragmentMass(Sequence),
                                                                  ionTable));
                }
            }

            MoleculeMassesObj = moleculeMasses;

            // Get values of interest from the settings.
            TransitionSettings = settings.TransitionSettings;

            // Get potential losses to all fragments in this peptide
            PotentialLosses = TransitionGroup.CalcPotentialLosses(Sequence, settings.PeptideSettings.Modifications,
                                                                  lookupMods, MassType);
        }
Ejemplo n.º 7
0
        public override void Render(Painter painter)
        {
            int  numChildren         = _children.Count;
            uint frameId             = painter.FrameId;
            bool cacheEnabled        = frameId != 0;
            bool selfOrParentChanged = _lastParentOrSelfChangeFrameID == frameId;

            for (int i = 0; i < numChildren; ++i)
            {
                DisplayObject child = _children[i];

                if (child._hasVisibleArea)
                {
                    if (selfOrParentChanged)
                    {
                        child._lastParentOrSelfChangeFrameID = frameId;
                    }

                    if (child._lastParentOrSelfChangeFrameID != frameId &&
                        child._lastChildChangeFrameID != frameId &&
                        child._tokenFrameID == frameId - 1 && cacheEnabled)
                    {
                        painter.PushState(SCacheToken);
                        painter.DrawFromCache(child._pushToken, child._popToken);
                        painter.PopState(child._popToken);

                        child._pushToken.CopyFrom(SCacheToken);
                    }
                    else
                    {
                        BatchToken     pushToken = cacheEnabled ? child._pushToken : null;
                        BatchToken     popToken  = cacheEnabled ? child._popToken : null;
                        FragmentFilter filter    = child._filter;
                        DisplayObject  mask      = child._mask;

                        painter.PushState(pushToken);
                        painter.SetStateTo(child.TransformationMatrix, child.Alpha, child.BlendMode);

                        if (mask != null)
                        {
                            painter.DrawMask(mask, child);
                        }

                        if (filter != null)
                        {
                            filter.Render(painter);
                        }
                        else
                        {
                            child.Render(painter);
                        }

                        if (mask != null)
                        {
                            painter.EraseMask(mask, child);
                        }

                        painter.PopState(popToken);
                    }

                    if (cacheEnabled)
                    {
                        child._tokenFrameID = frameId;
                    }
                }
            }
        }