Example #1
0
        /// <summary>
        /// Copies the target parameter to a new IqTarget.
        /// </summary>
        /// <param name="target">target parameter</param>
        public IqTarget(IqTarget target)
            : this()
        {
            var util = new IqTargetUtilities();

            util.CopyTargetProperties(target, this);
        }
        /// <summary>
        /// clones trees for root, parents and children and sets the correct node
        /// </summary>
        /// <param name="target">target we want to clone</param>
        /// <returns></returns>
        private static IqTarget CloneIqTrees(IqTarget target)
        {
            //initialize utilities
            var util = new IqTargetUtilities();

            //find root
            var rootNode = target.RootTarget;

            //this returnes the copied tree
            var tempTarget = util.Clone(rootNode);

            //select current node along the tree.  we need to mangle the charge and the ID to ensure uniqueness
            var selectID          = target.ID;
            var selectChargeState = target.ChargeState;

            var targetList = new List <IqTarget>();

            targetList.Add(tempTarget);

            var nodeLevelTargets = util.GetTargetsFromNodelLevel(targetList, target.NodeLevel);

            var s = (from n in nodeLevelTargets where n.ID == selectID && n.ChargeState == selectChargeState select n).Take(1).ToList();

            return(s[0]);
        }
        /// <summary>
        /// clones simple properties and deeper trees
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public IqTarget DeepClone(IqTarget target)
        {
            var util = new IqTargetUtilities();

            //basic copy

            //TODO: the problem is here is we are creating an IqTargetBasic, which might not fit everyone's liking
            IqTarget copiedTarget = new IqTargetBasic();

            CopyTargetProperties(target, copiedTarget);

            //this returnes the copied tree
            var deepCopy = CloneIqTrees(target);

            //set root via private set
            copiedTarget.RootTarget = deepCopy.RootTarget;

            //set parent target
            copiedTarget.ParentTarget = deepCopy.ParentTarget;

            //set the child targets
            var childTargets = deepCopy.ChildTargets().ToList();

            if (deepCopy.HasChildren() && childTargets.Count > 0)
            {
                foreach (var subtarget in childTargets)
                {
                    copiedTarget.AddTarget(subtarget);
                }
            }

            return(copiedTarget);
        }
        protected TargetCollection GetMassTagTargets(string massTagFileName, List <int> targetIDsToFilterOn)
        {
            if (String.IsNullOrEmpty(massTagFileName) || !File.Exists(massTagFileName))
            {
                return(new TargetCollection());
            }


            if (massTagFileName.ToLower().Contains("_msgfplus.tsv"))
            {
                var iqTargetImporter = new BasicIqTargetImporter(massTagFileName);
                var iqTargets        = iqTargetImporter.Import();

                var targetUtilities  = new IqTargetUtilities();
                var targetCollection = new TargetCollection
                {
                    TargetList = new List <TargetBase>()
                };

                foreach (var iqTarget in iqTargets)
                {
                    if (iqTarget.QualityScore > MsgfFdrScoreCutoff)
                    {
                        continue;
                    }
                    targetUtilities.UpdateTargetMissingInfo(iqTarget);

                    TargetBase oldStyleTarget = new PeptideTarget();
                    oldStyleTarget.ChargeState      = (short)iqTarget.ChargeState;
                    oldStyleTarget.Code             = iqTarget.Code;
                    oldStyleTarget.EmpiricalFormula = iqTarget.EmpiricalFormula;
                    oldStyleTarget.ID = iqTarget.ID;
                    oldStyleTarget.MZ = iqTarget.MZTheor;
                    oldStyleTarget.MonoIsotopicMass      = iqTarget.MonoMassTheor;
                    oldStyleTarget.ScanLCTarget          = iqTarget.ScanLC;
                    oldStyleTarget.NormalizedElutionTime = (float)iqTarget.ElutionTimeTheor;

                    oldStyleTarget.ElutionTimeUnit = DeconTools.Backend.Globals.ElutionTimeUnit.ScanNum;
                    targetCollection.TargetList.Add(oldStyleTarget);
                }

                return(targetCollection);
            }


            var importer = new MassTagFromTextFileImporter(massTagFileName);

            return(importer.Import(targetIDsToFilterOn));
        }
        protected virtual TargetCollection GetLcmsFeatureTargets(string targetsFilePath)
        {
            if (targetsFilePath.ToLower().Contains("_msgf"))
            {
                var iqTargetImporter = new BasicIqTargetImporter(targetsFilePath);
                var iqTargets        = iqTargetImporter.Import();

                var targetUtilities  = new IqTargetUtilities();
                var targetCollection = new TargetCollection();
                targetCollection.TargetList = new List <TargetBase>();

                foreach (var iqTarget in iqTargets)
                {
                    if (iqTarget.QualityScore > MsgfFdrScoreCutoff)
                    {
                        continue;
                    }
                    targetUtilities.UpdateTargetMissingInfo(iqTarget);

                    TargetBase oldStyleTarget = new LcmsFeatureTarget();
                    oldStyleTarget.ChargeState      = (short)iqTarget.ChargeState;
                    oldStyleTarget.Code             = iqTarget.Code;
                    oldStyleTarget.EmpiricalFormula = iqTarget.EmpiricalFormula;
                    oldStyleTarget.ID = iqTarget.ID;
                    oldStyleTarget.MZ = iqTarget.MZTheor;
                    oldStyleTarget.MonoIsotopicMass      = iqTarget.MonoMassTheor;
                    oldStyleTarget.ScanLCTarget          = iqTarget.ScanLC;
                    oldStyleTarget.NormalizedElutionTime = (float)iqTarget.ElutionTimeTheor;

                    oldStyleTarget.ElutionTimeUnit = DeconTools.Backend.Globals.ElutionTimeUnit.ScanNum;
                    targetCollection.TargetList.Add(oldStyleTarget);
                }

                return(targetCollection);
            }

            var importer =
                new LcmsTargetFromFeaturesFileImporter(targetsFilePath);

            var lcmsTargetCollection = importer.Import();

            return(lcmsTargetCollection);
        }
 public ChargeStateChildIqWorkflow(TargetedWorkflowParameters parameters) : base(parameters)
 {
     TargetUtilities = new IqTargetUtilities();
 }