예제 #1
0
        }                                                  // max index for _theoreticalIsotopomerEnvelope, not for this
        private IsotopomerFeatures(ImsDataCached imsData, Ion ion, Feature precursorFeature, bool isPrecurosr)
        {
            //  BinningMultiplyFactor = 6;
            if (ion.Charge >= 3)
            {
                BinningMultiplyFactor = 1;
            }
            //else if (ion.Charge == 1) BinningMultiplyFactor = 6;
            //else if (ion.Charge == 2) BinningMultiplyFactor = 2;
            else
            {
                BinningMultiplyFactor = 2;
            }

            var te = ion.Composition.GetIsotopomerEnvelopeRelativeIntensities();

            TheoreticalIsotopomerEnvelope = new double[(te.Length + FeatureNode.OffsetFromMonoIsotope) * BinningMultiplyFactor];
            for (var i = FeatureNode.OffsetFromMonoIsotope; i < te.Length + FeatureNode.OffsetFromMonoIsotope; i++)
            {
                TheoreticalIsotopomerEnvelope[i * BinningMultiplyFactor] = te[i - FeatureNode.OffsetFromMonoIsotope];
            }

            MaxIntensityIndex = GetMaximumIndex(TheoreticalIsotopomerEnvelope);
            //
            var start = -FeatureNode.OffsetFromMonoIsotope * BinningMultiplyFactor;

            for (var i = start; i < TheoreticalIsotopomerEnvelope.Length + start; i++)
            {
                var mz = ion.GetIsotopeMz((float)i / BinningMultiplyFactor);
                if (isPrecurosr)
                {
                    if (mz > imsData.MaxPrecursorMz || mz < imsData.MinPrecursorMz)
                    {
                        Add(null);
                    }
                    else
                    {
                        Add(imsData.GetPrecursorFeature(mz, precursorFeature));
                    }
                }
                else
                {
                    if (mz > imsData.MaxFragmentMz || mz < imsData.MinFragmentMz)
                    {
                        Add(null);
                    }
                    else
                    {
                        Add(imsData.GetFramentFeature(mz, precursorFeature));
                    }
                    //var tt = imsData.GetFramentFeature(mz, precursorFeature);
                    // if(mz == 361.198813765)
                    //    Console.WriteLine(mz + " " + (tt == null ? "NULL" : tt.GetHighestPoint().ToString()));
                }
            }
        }
예제 #2
0
        public FragmentFeatureGraph(ImsDataCached imsData, PrecursorFeatureNode precursorNode, Feature precursorFeature,
                                    Ion precursorIon, Composition cutComposition, GroupParameter parameter, SubScoreFactory scoringParams)
        {
            _scoringParams        = scoringParams;
            _precursorFeatureNode = precursorNode;

            Add(precursorNode, new List <FeatureEdge>());
            var fragmentNodes = GetFragmentNodes(imsData, precursorFeature, cutComposition, precursorIon, parameter);

            supportingIonTypes = new List <IonType>();
            foreach (var node in fragmentNodes)
            {
                if (node.Feature != null)
                {
                    supportingIonTypes.Add(node.FragmentIonClassBase);
                }
            }
            //var nn = fragmentNodes.Count(no => no.Feature != null);
            //Console.WriteLine(this + "Num features : " + nn);


            var usedNodes = new List <FeatureNode> {
                precursorNode
            };

            UpdateEdges(fragmentNodes, usedNodes); // from precursor to any of fragment nodes
            if (this[precursorNode].Count == 0)
            {
                NodeScore = RatioScore = -1; //TODO should be trained..
                Score     = NodeScore + RatioScore;
                return;
            }
            // usedNodes.Remove(precursorNode);// exclude precursorNode
            var primeNode   = (FragmentFeatureNode)this[precursorNode][0].RNode;
            var targetNodes = GetTargetNodes(primeNode, fragmentNodes, true, false);

            UpdateEdges(targetNodes, usedNodes); // to the nodes of different terminal ions
            targetNodes = GetTargetNodes(primeNode, fragmentNodes, false, false);

            UpdateEdges(targetNodes, usedNodes); // to the nodes of the same terminal ions
            targetNodes = GetTargetNodes(primeNode, fragmentNodes, true, true);
            UpdateEdges(targetNodes, usedNodes); // to the nodes of differently charged ions

            GetScore();
        }
예제 #3
0
        private List <FragmentFeatureNode> GetFragmentNodes(ImsDataCached imsData, Feature precursorFeature, Composition cutComposition, Ion precursorIon, GroupParameter parameter)
        {
            var ionTypes = _scoringParams.GetIonTypes(parameter);

            var nodes             = new List <FragmentFeatureNode>();
            var suffixComposition = precursorIon.Composition - Composition.H2O - cutComposition;

            //Console.WriteLine(cutComposition.GetMass() + " " + suffixComposition.GetMass());

            foreach (var ionType in ionTypes)
            {
                var composition = ionType.IsPrefixIon ? cutComposition : suffixComposition;
                //Console.WriteLine("FragFeatureGraph\t" + ionType.Name + "\t" + composition.GetMass() + "\t" + ionType.GetIon(composition).GetMonoIsotopicMz());
                var node = new FragmentFeatureNode(IsotopomerFeatures.GetFramentIsotopomerFeatures(imsData, composition, ionType, precursorFeature), ionType, precursorFeature, parameter, _scoringParams);
                //if(node.Feature != null)
                //    if (20 * node.Feature.IntensityMax < precursorFeature.IntensityMax || node.Feature.IntensityMax > 20 * precursorFeature.IntensityMax) continue; //

                nodes.Add(node);
            }
            return(nodes);
        }
예제 #4
0
 public void RegisterImsData(ImsDataCached imsData, ImsScorerFactory imsScorerFactory)
 {
     _imsData = imsData;
     _imsScorerFactory = imsScorerFactory;
 }
예제 #5
0
 internal ImsScorer(ImsDataCached imsData, Ion precursorIon, SubScoreFactory scoringParams) // precursorComposition does not have protons; however, protons are incorporated when calculating mz
 {
     _imsData       = imsData;
     _precursorIon  = precursorIon;
     _scoringParams = scoringParams;
 }
예제 #6
0
 public ImsScorer GetImsScorer(ImsDataCached imsData, Ion precursorIon)
 {
     return(new ImsScorer(imsData, precursorIon, _subScoreFactory));
 }
예제 #7
0
 static public IsotopomerFeatures GetPrecursorIsotopomerFeatures(ImsDataCached imsData, Ion precursorIon, Feature precursorFeature)
 {
     return(new IsotopomerFeatures(imsData, precursorIon, precursorFeature, true));
 }
예제 #8
0
 static public IsotopomerFeatures GetFramentIsotopomerFeatures(ImsDataCached imsData, Composition cutComposition, IonType fragmentIonClassBase, Feature precursorFeature)
 {
     return(new IsotopomerFeatures(imsData, fragmentIonClassBase.GetIon(cutComposition), precursorFeature, false));
 }