コード例 #1
0
        private void AddTransitionRecord(ITransition transitionRecord)
        {
            TransitionRecord record = new TransitionRecord();

            record.transition = transitionRecord;
            record.time       = Time.time;
            record.gameObject = stateMachine.Component.gameObject;
            record.stackTrace = new System.Diagnostics.StackTrace(true);
            record.index      = g_nextTransitionIndex;
            g_nextTransitionIndex++;


            transitionHistory.Add(record);
            if (transitionHistory.Count > transitionHistorySize)
            {
                transitionHistory.RemoveAt(0);
            }

            // add to global history
            g_transitionHistory.Add(record);
            if (g_transitionHistory.Count > g_transitionHistorySize)
            {
                g_transitionHistory.RemoveAt(0);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: rfellers/pwiz
        private static Dictionary <string, List <TransitionRecord> > GetTransitions(string reportLocation)
        {
            var csv = new CsvReader(File.OpenText(reportLocation),
                                    new CsvConfiguration {
                CultureInfo = CultureInfo.InvariantCulture
            });
            // loops through each row as csv.CurrentRecord
            var peptideTransitions = new Dictionary <string, List <TransitionRecord> >();

            // creates dictionary from Skyline report of peptides -> precursors
            while (csv.Read())
            {
                try
                {
                    var proteinName             = csv.GetField <string>(0);
                    var peptideModifiedSequence = csv.GetField <string>(1);
                    var isotopeLabelType        = csv.GetField <string>(2);
                    var modifiedSequence        = csv.GetField <string>(3);
                    // ReSharper disable InconsistentNaming
                    var TFExport_IntegrationStrategy = csv.GetField <string>(4);
                    var TFExport_WindowType          = csv.GetField <string>(5);
                    var TFExport_WorkFlow            = csv.GetField <string>(6);
                    // ReSharper restore InconsistentNaming
                    var precursorMz       = csv.GetField <double>(7);
                    var productMz         = csv.GetField <double>(8);
                    var productCharge     = csv.GetField <int>(9);
                    var bestRetentionTime = csv.GetField <string>(10);
                    var fragmentIon       = csv.GetField <string>(11);
                    var fragmentIonType   = csv.GetField <string>(12);
                    var standardType      = csv.GetField <string>(13);
                    var collisionEnergy   = csv.GetField <string>(14);
                    var retentionTime     = csv.GetField <string>(15);
                    var fileName          = csv.GetField <string>(16);
                    var area            = csv.GetField <string>(17);
                    var precursorCharge = csv.GetField <int>(18);
                    double.TryParse(area, out var areaInt);

                    var record = new TransitionRecord(proteinName, peptideModifiedSequence, isotopeLabelType,
                                                      modifiedSequence,
                                                      TFExport_IntegrationStrategy, TFExport_WindowType, TFExport_WorkFlow, precursorMz, productMz,
                                                      productCharge,
                                                      bestRetentionTime, fragmentIon, fragmentIonType, standardType,
                                                      collisionEnergy, fileName, retentionTime, areaInt, precursorCharge);
                    var key = record.ProteinName + "-" + record.PeptideModifiedSequence;
                    if (!peptideTransitions.ContainsKey(key))
                    {
                        peptideTransitions.Add(key, new List <TransitionRecord>());
                    }
                    peptideTransitions[key].Add(record);
                }
                catch (Exception)
                {
                    throw new IOException("There was an issue processing the Skyline report. Ensure that the tool is using the TFExport report in Skyline.");
                }
            }
            return(peptideTransitions);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: rfellers/pwiz
        private static string GetKey(TransitionRecord tr)
        {
            var key = tr.ModifiedSequence + KEY_SEP +
                      tr.PrecursorMz.ToString(CultureInfo.InstalledUICulture) + KEY_SEP +
                      tr.FragmentIon + KEY_SEP +
                      tr.IsotopeLabelType + KEY_SEP +
                      tr.ProductMz.ToString(CultureInfo.InvariantCulture);

            return(key);
        }
コード例 #4
0
        /// <param name="transition"></param>
        /// <param name="lNum">レイヤー番号</param>
        /// <param name="smNum">ステートマシン番号</param>
        /// <param name="sNum">ステート番号</param>
        /// <param name="tNum">トランジション番号</param>
        /// <returns></returns>
        public override bool OnTransition(AnimatorStateTransition transition, int lNum, int smNum, int sNum, int tNum)
        {
            TransitionRecord transitionRecord = new TransitionRecord(
                lNum,
                smNum,
                sNum,
                tNum,
                transition, "");

            AconDocument.transitions.Add(transitionRecord); return(true);
        }
コード例 #5
0
 private string GetTransitionKey(TransitionRecord transitionRecord)
 {
     return("@" + transitionRecord.SourceActivityRecord.Id + "_" + transitionRecord.SourceEndpoint);
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: rfellers/pwiz
        private static void WriteToCsv(string saveLocation, Dictionary <string, List <TransitionRecord> > peptideTransitions)
        {
            int startRow = 6;
            int rowCount = 0;

            foreach (var peptide in peptideTransitions.Values)
            {
                rowCount += peptide.Count;
            }

            // Auto Fill Transition Workflow information
            AutoFillTransitions(peptideTransitions);
            // Validate rows : No longer used
            // Ensure necessary data exists to export a TF formatted file
//            ValidateTransitions(peptideTransitions);

            const string emptyLine = ",,,,,,,,,,,,,,,,,,,,,,,,";
            var          csvLines  = new List <string>
            {
                "TraceFinder Compound Database Mass List Export,,,,,,,,,,,,,,,,,,,,,,,,",
                emptyLine,
                "Schema Version,Peak Header Line Number,Peak Last Row Line Number,Compound Header Line Number,,,,,,,,,,,,,,,,,,,,,",
                string.Format("1,{0},{1},{2},,,,,,,,,,,,,,,,,,,,,", startRow, rowCount + startRow, rowCount + startRow + 2),
                ",,,,,,,,,,,,,,,,,,,,,,,,",
                "Protein Name,Compound Name,Workflow,Associated Target Peak,MS Order,Precursor m/z,Product m/z,m/z,Height Threshold,Area Threshold,Collision Energy,Modification,Lens,Energy Ramp,Ion Coelution,Ratio Window,Target Ratio,Window Type,Ion Type,PeakPolarity,Adduct,Charge State,Retention Time,Retention Time Window,Integration Strategy"
            }; // each object is a line that will be outputted when the result csv file is saved
               // Header row/version info
               // line1
               // line2
               // line3
               // line4
               // line5
               // First section column headers
               // line6 - column headers
               // First section data rows

            Dictionary <string, List <TransitionRecord> > peptideAnalytes = new Dictionary <string, List <TransitionRecord> >();

            foreach (var pt in peptideTransitions)
            {
                var transitions = pt.Value;
                foreach (var transitionRecord in transitions)
                {
                    var newKey = pt.Key + transitionRecord.IsotopeLabelType;
                    if (!peptideAnalytes.ContainsKey(newKey))
                    {
                        peptideAnalytes.Add(newKey, new List <TransitionRecord>());
                    }
                    peptideAnalytes[newKey].Add(transitionRecord);
                }
            }
            foreach (var transitions in peptideAnalytes.Values)
            {
                // find transition with highest product mz, this will be the target peak
                TransitionRecord highestTransitionMz = null;
                var highestTransitionIndex           = 0;
                for (var i = 0; i < transitions.Count; i++)
                {
                    TransitionRecord transition = transitions[i];

                    if (highestTransitionMz == null && transition.TFExport_WorkFlow.Equals(TARGET_PEAK))
                    {
                        highestTransitionMz    = transition;
                        highestTransitionIndex = i + 1; // index starts at 1 instead of 0
                    }
                    if (highestTransitionMz != null && transition.ProductMz > highestTransitionMz.ProductMz &&
                        transition.TFExport_WorkFlow.Equals(TARGET_PEAK))
                    {
                        highestTransitionIndex = i + 1; // index starts at 1 instead of 0
                        highestTransitionMz    = transition;
                    }
                }
                foreach (TransitionRecord transition in transitions)
                {
                    var proteinName  = transition.ProteinName;
                    var compoundName = transition.PeptideModifiedSequence;
                    if (transition.IsotopeLabelType.Equals("heavy"))
                    {
                        if (_internalStandardType == InternalStandardType.heavy)
                        {
                            compoundName += "[heavyIS]";
                        }
                        else if (_internalStandardType == InternalStandardType.none)
                        {
                            compoundName += "[heavy]";
                        }
                    }
                    else if (transition.IsotopeLabelType.Equals("light"))
                    {
                        if (_internalStandardType == InternalStandardType.light)
                        {
                            compoundName += "[lightIS]";
                        }
                        else if (_internalStandardType == InternalStandardType.none)
                        {
                            compoundName += "[light]";
                        }
                    }


                    var workflow             = transition.TFExport_WorkFlow;
                    var associatedTargetPeak = string.Empty;
                    var msOrder = "ms2";
                    if (transition.FragmentIonType.Equals("precursor"))
                    {
                        msOrder = "ms1";
                    }
                    var precursorMz = transition.PrecursorMz;
                    var productMz   = transition.ProductMz.ToString(CultureInfo.InvariantCulture);
                    if (msOrder.Equals("ms1"))
                    {
                        productMz = string.Empty;
                    }
                    var mz = transition.PrecursorMz;
                    var heightThreshold = string.Empty;
                    var areaThreshold   = string.Empty;
                    var collisionEnergy = transition.CollisionEnergy;
                    var modification    = transition.IsotopeLabelType;
                    var lens            = 0;
                    var energyRamp      = 0;
                    var ionCoelution    = string.Empty;
                    var ratioWindow     = string.Empty;
                    var targetRatio     = string.Empty;
                    var windowType      = transition.TFExport_WindowType;
                    var ionType         = transition.FragmentIon;

                    var peakPolarity = string.Empty;
                    var adduct       = string.Empty;

                    if (transition.TFExport_WorkFlow.Equals(CONFIRMING) ||
                        transition.TFExport_WorkFlow.Equals(FRAGMENT))
                    {
                        associatedTargetPeak = highestTransitionIndex.ToString();
                    }

                    if (transition.ProductCharge > 0) // should never never be 0 or less
                    {
                        peakPolarity = "Positive";
                        adduct       = "M+";
                    }

                    var chargeState = transition.ProductCharge;
                    if (chargeState < 0) // should never happen
                    {
                        chargeState = 0;
                    }
                    var retentionTime = transition.RetentionTime;
                    if (_useAvgRt)
                    {
                        retentionTime = transition.BestRetentionTime;
                    }

                    if (retentionTime.Equals("#N/A"))
                    {
                        retentionTime = string.Empty;
                    }
                    var retentionTimeWindow = _rtWindow;
                    var integrationStrategy = transition.TFExport_IntegrationStrategy;

                    csvLines.Add(string.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17}," +
                                               "{18},{19},{20},{21},{22},{23},{24}",
                                               proteinName, compoundName, workflow, associatedTargetPeak, msOrder, precursorMz, productMz, mz, heightThreshold,
                                               areaThreshold, collisionEnergy, modification, lens, energyRamp, ionCoelution, ratioWindow, targetRatio, windowType, ionType,
                                               peakPolarity, adduct, chargeState, retentionTime, retentionTimeWindow, integrationStrategy));
                }
            }
            csvLines.Add(emptyLine); // add empty line to break for second section
            // Second section column headers
            csvLines.Add("Protein Name,Compound Name,Peptide Sequence,Cas Number,Category,Compound Type,Internal Standard Concentration,ISTD Protein Name,ISTD Compound Name,Ionization Field,Compound Group,,,,,,,,,,,,,,");
            // Second section data rows
            foreach (var transitions in peptideTransitions.Values)
            {
                transitions.Sort((a, b) => a.PrecursorMz.CompareTo(b.PrecursorMz));
                bool heavyUsed = false;
                bool lightUsed = false;
                foreach (TransitionRecord transition in transitions)
                {
                    if (!heavyUsed && transition.IsotopeLabelType.Equals("heavy"))
                    {
                        heavyUsed = true;
                        var proteinName  = transition.ProteinName;
                        var compoundName = transition.PeptideModifiedSequence;
                        if (_internalStandardType == InternalStandardType.heavy)
                        {
                            compoundName += "[heavyIS]";
                        }
                        else
                        {
                            compoundName += "[heavy]";
                        }
                        var peptideSequence = transition.PeptideModifiedSequence;
                        var casNumber       = string.Empty;
                        var category        = string.Empty;
                        var compoundType    = string.Empty;
                        var internalStandardConcentration = string.Empty;
                        var iStdProteinName  = string.Empty;
                        var iStdCompoundName = string.Empty;
                        var ionizationField  = "None";
                        var compoundGroup    = string.Empty;

                        csvLines.Add(
                            string.Format(CultureInfo.InvariantCulture,
                                          "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},,,,,,,,,,,,,,", proteinName, compoundName,
                                          peptideSequence, casNumber, category, compoundType, internalStandardConcentration, iStdProteinName,
                                          iStdCompoundName, ionizationField, compoundGroup));
                    }
                    if (!lightUsed && transition.IsotopeLabelType.Equals("light"))
                    {
                        lightUsed = true;
                        var proteinName  = transition.ProteinName;
                        var compoundName = transition.PeptideModifiedSequence;
                        if (_internalStandardType == InternalStandardType.light)
                        {
                            compoundName += "[lightIS]";
                        }
                        else
                        {
                            compoundName += "[light]";
                        }

                        var peptideSequence = transition.PeptideModifiedSequence;
                        var casNumber       = string.Empty;
                        var category        = string.Empty;
                        var compoundType    = string.Empty;
                        var internalStandardConcentration = string.Empty;
                        var iStdProteinName  = string.Empty;
                        var iStdCompoundName = string.Empty;
                        var ionizationField  = "None";
                        var compoundGroup    = string.Empty;

                        csvLines.Add(
                            string.Format(CultureInfo.InvariantCulture,
                                          "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},,,,,,,,,,,,,,", proteinName, compoundName,
                                          peptideSequence, casNumber, category, compoundType, internalStandardConcentration, iStdProteinName,
                                          iStdCompoundName, ionizationField, compoundGroup));
                    }
                }
            }

            using (var outfile = new StreamWriter(saveLocation))
            {
                foreach (var line in csvLines)
                {
                    outfile.WriteLine(line);
                }
            }
        }
コード例 #7
0
        public void CreateSendEmailToFollowersWorkflow()
        {
            WorkflowDefinitionRecord workflow = new WorkflowDefinitionRecord {
                Name = this.SendEmailToFollowersTicket, Enabled = true
            };

            this.workflowDefinitionRepository.Create(workflow);
            var emailTemplate = this.emailTemplatesRepository.Table.FirstOrDefault(c => c.TypeId == (int)EmailTemplateType.FollowersNotification);

            if (emailTemplate == null)
            {
                throw new NullReferenceException();
            }

            ActivityRecord itemPublishRecord = new ActivityRecord
            {
                WorkflowDefinitionRecord = workflow,
                Start = true,
                X     = 552,
                Y     = 227,
                State = "{}",
                Name  = NewActivityStreamActivity.ActivityStreamActivityName
            };

            this.activityRepository.Create(itemPublishRecord);

            ActivityRecord timerActivity = new ActivityRecord
            {
                WorkflowDefinitionRecord = workflow,
                Start = false,
                X     = 552,
                Y     = 388,
                State = "{\"Amount\":\"1\",\"Unity\":\"Minute\"}",
                Name  = OrchardCollaborationTimerActivity.ActionName
            };

            this.activityRepository.Create(timerActivity);

            ActivityRecord sendEmailActivityRecord = new ActivityRecord
            {
                State = string.Format(
                    CultureInfo.InvariantCulture,
                    "{{\"{0}\":\"{1}\"}}",
                    EmailTemplateActivityForm.EmailTemplateIdFieldName,
                    emailTemplate.Id.ToString(CultureInfo.InvariantCulture)),
                Name = "SendEmailToFollowersActivity",
                WorkflowDefinitionRecord = workflow,
                X     = 494,
                Y     = 588,
                Start = false
            };

            this.activityRepository.Create(sendEmailActivityRecord);

            TransitionRecord timerTransitionRecord = new TransitionRecord
            {
                WorkflowDefinitionRecord  = workflow,
                DestinationActivityRecord = timerActivity,
                SourceActivityRecord      = itemPublishRecord,
                DestinationEndpoint       = "",
                SourceEndpoint            = "Done"
            };

            this.transitionRepository.Create(timerTransitionRecord);

            TransitionRecord sendEmailTransitionRecord = new TransitionRecord
            {
                WorkflowDefinitionRecord  = workflow,
                DestinationActivityRecord = sendEmailActivityRecord,
                SourceActivityRecord      = timerActivity,
                DestinationEndpoint       = "",
                SourceEndpoint            = "Done"
            };

            this.transitionRepository.Create(sendEmailTransitionRecord);

            this.workflowDefinitionRepository.Flush();
            this.activityRepository.Flush();
            this.transitionRepository.Flush();
        }
コード例 #8
0
        private void CreateCRMCommentWorkflow()
        {
            WorkflowDefinitionRecord workflow = new WorkflowDefinitionRecord {
                Name = this.CreateTicketCommentsWorkflowName, Enabled = true
            };

            this.workflowDefinitionRepository.Create(workflow);
            var emailTemplate = this.emailTemplatesRepository.Table.FirstOrDefault(c => c.TypeId == (int)EmailTemplateType.NewMessage);

            if (emailTemplate == null)
            {
                throw new NullReferenceException();
            }

            ActivityRecord crmCommentPublishRecord = new ActivityRecord
            {
                WorkflowDefinitionRecord = workflow,
                Start = true,
                X     = 552,
                Y     = 227,
                State = "{\"ContentTypes\":\"CRMComment\"}",
                Name  = "ContentPublished"
            };

            this.activityRepository.Create(crmCommentPublishRecord);

            ActivityRecord timerActivity = new ActivityRecord
            {
                WorkflowDefinitionRecord = workflow,
                Start = false,
                X     = 552,
                Y     = 388,
                State = "{\"Amount\":\"1\",\"Unity\":\"Minute\"}",
                Name  = OrchardCollaborationTimerActivity.ActionName
            };

            this.activityRepository.Create(timerActivity);

            ActivityRecord sendEmailCRMCommentActivity = new ActivityRecord
            {
                State = string.Format(
                    CultureInfo.InvariantCulture,
                    "{{\"{0}\":\"{1}\",\"{2}\":\"true\",\"{3}\":\"true\"}}",
                    EmailTemplateActivityForm.EmailTemplateIdFieldName,
                    emailTemplate.Id.ToString(CultureInfo.InvariantCulture),
                    EmailTemplateActivityForm.SentToRequestingUserFieldName,
                    EmailTemplateActivityForm.SentToOwnerFieldName
                    ),
                Name = "SendTicketEmailActivity",
                WorkflowDefinitionRecord = workflow,
                X     = 494,
                Y     = 588,
                Start = false
            };

            this.activityRepository.Create(sendEmailCRMCommentActivity);

            TransitionRecord timerTransitionRecord = new TransitionRecord
            {
                WorkflowDefinitionRecord  = workflow,
                DestinationActivityRecord = timerActivity,
                SourceActivityRecord      = crmCommentPublishRecord,
                DestinationEndpoint       = "",
                SourceEndpoint            = "Done"
            };

            this.transitionRepository.Create(timerTransitionRecord);

            TransitionRecord sendEmailCRMCommentTransitionRecord = new TransitionRecord
            {
                WorkflowDefinitionRecord  = workflow,
                DestinationActivityRecord = sendEmailCRMCommentActivity,
                SourceActivityRecord      = timerActivity,
                DestinationEndpoint       = "",
                SourceEndpoint            = "Done"
            };

            this.transitionRepository.Create(sendEmailCRMCommentTransitionRecord);

            this.workflowDefinitionRepository.Flush();
            this.activityRepository.Flush();
            this.transitionRepository.Flush();
        }
コード例 #9
0
        private void CreateTicketForReceivedEmailsWorkflow()
        {
            WorkflowDefinitionRecord workflow = new WorkflowDefinitionRecord {
                Name = this.CreateTicketForRecievedEmailWorkflowName, Enabled = true
            };

            this.workflowDefinitionRepository.Create(workflow);

            ActivityRecord emailReceivedRecord = new ActivityRecord
            {
                WorkflowDefinitionRecord = workflow,
                Start = true,
                State = "{}",
                X     = 552,
                Y     = 227,
                Name  = IMapEmailReceivedActivity.ActivityName
            };

            this.activityRepository.Create(emailReceivedRecord);

            ActivityRecord checkEmailBelongToUserActivityRecord = new ActivityRecord
            {
                State = "{}",
                Name  = "CheckEmailBelongToUser",
                WorkflowDefinitionRecord = workflow,
                X     = 494,
                Y     = 538,
                Start = false
            };

            this.activityRepository.Create(checkEmailBelongToUserActivityRecord);

            TransitionRecord transitionRecord1 = new TransitionRecord
            {
                WorkflowDefinitionRecord  = workflow,
                DestinationActivityRecord = checkEmailBelongToUserActivityRecord,
                SourceActivityRecord      = emailReceivedRecord,
                DestinationEndpoint       = "",
                SourceEndpoint            = "Done"
            };

            this.transitionRepository.Create(transitionRecord1);

            ActivityRecord createTicketActivityRecord = new ActivityRecord
            {
                State = "{\"EditableBy\":\"{EEmail.UserName}\",\"Title\":\"{EEmail.Subject}\",\"Description\":\"{EEmail.Body}\",\"DownloadEmailAttachments\":\"true\"}",
                Name  = CreateTicketActivity.ActivityName,
                WorkflowDefinitionRecord = workflow,
                X     = 494,
                Y     = 688,
                Start = false
            };

            this.activityRepository.Create(createTicketActivityRecord);

            TransitionRecord transitionRecord2 = new TransitionRecord
            {
                WorkflowDefinitionRecord  = workflow,
                DestinationActivityRecord = createTicketActivityRecord,
                SourceActivityRecord      = checkEmailBelongToUserActivityRecord,
                DestinationEndpoint       = "",
                SourceEndpoint            = "Yes"
            };

            this.transitionRepository.Create(transitionRecord2);

            this.workflowDefinitionRepository.Flush();
            this.activityRepository.Flush();
            this.transitionRepository.Flush();
        }