private void process_Exited(object sender, EventArgs e) { if (ProcessingEvent != null) { ProcessingEvent.Invoke(ProcessEvent.ProcessExit); } }
/// <summary> /// Processing Test ID 001, 002, and 003 /// Register processing metadata /// </summary> /// <returns></returns> public static ProcessingEvent CreateProcessingMetatata() { // create a processing event var processing = new ProcessingEvent(); processing.Label["en"] = "Sample processing"; processing.Label["fr"] = "Traitement des échantillons"; processing.OtherAppraisalProcess["en"] = "Describe the appraisal process"; processing.OtherAppraisalProcess["fr"] = "Décrire le processus d'évaluation"; // create a description of the organization doing the processing var statCan = new Organization(); statCan.ItemName["en"] = "Statistics Canada"; statCan.ItemName["fr"] = "Statistique Canada"; // Describe a cleaning operation processing.CleaningOperation.Organizations.Add(statCan); processing.CleaningOperation.Description["en"] = "Description of the data cleaning."; processing.CleaningOperation.Description["fr"] = "Description du nettoyage des données."; // Describe a control operation processing.ControlOperation.Organizations.Add(statCan); processing.ControlOperation.Description["en"] = "Description of the data control method."; processing.ControlOperation.Description["fr"] = "Description de la méthode de contrôle des données."; return(processing); }
private void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine) { _logging.Add(outLine.Data); if (ProcessingEvent != null) { ProcessingEvent.Invoke(ProcessEvent.MessageRecieved); } }
private void ProcessFail(Exception e) { _LastException = e; if (ProcessingEvent != null) { ProcessingEvent.Invoke(ProcessEvent.PrcossExitWithFail); } }
private void Initialize(ProcessingEvent processingevent, string testName, string stepAction, int stepNumber, int elementNumber, int expectedResponseNumber) { Event = processingevent; TestName = testName; StepAction = stepAction; StepNumber = stepNumber; ElementNumber = elementNumber; ExpectedResponseNumber = expectedResponseNumber; }
public string RegisterProcessingEvent <T>(params object[] args) where T : IEventProcessor { string globalID = Guid.NewGuid().ToString(); ProcessingEvent @event = new ProcessingEvent(typeof(T), args); _cache.ProcessingEvents.Add(globalID, @event); return(globalID); }
void IQueueMessageHandler.Handle(QueueMessage queueMessage, IMessageContext context) { var message = _jsonSerializer.Deserialize <EventStreamMessage>(Encoding.UTF8.GetString(queueMessage.Body)); var domainEventStreamMessage = ConvertToDomainEventStream(message); var processContext = new DomainEventStreamProcessContext(this, domainEventStreamMessage, queueMessage, context); var processingMessage = new ProcessingEvent(domainEventStreamMessage, processContext); _logger.DebugFormat("ENode event stream message received, messageId: {0}, aggregateRootId: {1}, aggregateRootType: {2}, version: {3}", domainEventStreamMessage.Id, domainEventStreamMessage.AggregateRootId, domainEventStreamMessage.AggregateRootTypeName, domainEventStreamMessage.Version); _messageProcessor.Process(processingMessage); }
public Task HandleAsync(KafkaMessage kafkaMessage, IKafkaMessageContext context) { var eNodeMessage = _jsonSerializer.Deserialize <ENodeMessage>(kafkaMessage.Message.Value); var eventStreamMessage = _jsonSerializer.Deserialize <EventStreamMessage>(eNodeMessage.Body); var domainEventStreamMessage = ConvertToDomainEventStream(eventStreamMessage); var processContext = new DomainEventStreamProcessContext(this, domainEventStreamMessage, kafkaMessage, context); var processingMessage = new ProcessingEvent(domainEventStreamMessage, processContext); _logger.DebugFormat("ENode event message received, messageId: {0}, aggregateRootId: {1}, aggregateRootType: {2}, version: {3}", domainEventStreamMessage.Id, domainEventStreamMessage.AggregateRootId, domainEventStreamMessage.AggregateRootTypeName, domainEventStreamMessage.Version); _messageProcessor.Process(processingMessage); return(Task.CompletedTask); }
private void DispatchProcessingMessageAsync(ProcessingEvent processingMessage, int retryTimes) { _ioHelper.TryAsyncActionRecursivelyWithoutResult("DispatchProcessingMessageAsync", () => _dispatcher.DispatchMessagesAsync(processingMessage.Message.Events), currentRetryTimes => DispatchProcessingMessageAsync(processingMessage, currentRetryTimes), () => { UpdatePublishedVersionAsync(processingMessage, 0); }, () => string.Format("Message[messageId:{0}, messageType:{1}, aggregateRootId:{2}, aggregateRootVersion:{3}]", processingMessage.Message.Id, processingMessage.Message.GetType().Name, processingMessage.Message.AggregateRootId, processingMessage.Message.Version), null, retryTimes, true); }
void IQueueMessageHandler.Handle(QueueMessage queueMessage, IMessageContext context) { var eventStreamMessageString = Encoding.UTF8.GetString(queueMessage.Body); _logger.InfoFormat("Received event stream equeue message: {0}, eventStreamMessage: {1}", queueMessage, eventStreamMessageString); var message = _jsonSerializer.Deserialize <EventStreamMessage>(eventStreamMessageString); var domainEventStreamMessage = ConvertToDomainEventStream(message); var processContext = new DomainEventStreamProcessContext(this, domainEventStreamMessage, queueMessage, context); var processingMessage = new ProcessingEvent(domainEventStreamMessage, processContext); _messageProcessor.Process(processingMessage); }
private void UpdatePublishedVersionAsync(ProcessingEvent processingMessage, int retryTimes) { var message = processingMessage.Message; _ioHelper.TryAsyncActionRecursivelyWithoutResult("UpdatePublishedVersionAsync", () => _publishedVersionStore.UpdatePublishedVersionAsync(Name, message.AggregateRootTypeName, message.AggregateRootId, message.Version), currentRetryTimes => UpdatePublishedVersionAsync(processingMessage, currentRetryTimes), () => { processingMessage.Complete(); }, () => string.Format("DomainEventStreamMessage [messageId:{0}, messageType:{1}, aggregateRootId:{2}, aggregateRootVersion:{3}]", message.Id, message.GetType().Name, message.AggregateRootId, message.Version), null, retryTimes, true); }
private void DispatchProcessingMessageAsync(ProcessingEvent processingMessage, int retryTimes) { _ioHelper.TryAsyncActionRecursively("DispatchProcessingMessageAsync", () => _dispatcher.DispatchMessagesAsync(processingMessage.Message.Events), currentRetryTimes => DispatchProcessingMessageAsync(processingMessage, currentRetryTimes), result => { UpdatePublishedVersionAsync(processingMessage, 0); }, () => string.Format("sequence message [messageId:{0}, messageType:{1}, aggregateRootId:{2}, aggregateRootVersion:{3}]", processingMessage.Message.Id, processingMessage.Message.GetType().Name, processingMessage.Message.AggregateRootId, processingMessage.Message.Version), errorMessage => { _logger.Fatal(string.Format("Dispatching message has unknown exception, the code should not be run to here, errorMessage: {0}", errorMessage)); }, retryTimes, true); }
private void UpdatePublishedVersionAsync(ProcessingEvent processingMessage, int retryTimes) { var message = processingMessage.Message; _ioHelper.TryAsyncActionRecursively("UpdatePublishedVersionAsync", () => _publishedVersionStore.UpdatePublishedVersionAsync(_processorName, message.AggregateRootTypeName, message.AggregateRootId, message.Version), currentRetryTimes => UpdatePublishedVersionAsync(processingMessage, currentRetryTimes), result => { processingMessage.Complete(); }, () => string.Format("DomainEventStreamMessage [messageId:{0}, messageType:{1}, aggregateRootId:{2}, aggregateRootVersion:{3}]", message.Id, message.GetType().Name, message.AggregateRootId, message.Version), errorMessage => { _logger.Fatal(string.Format("Update published version has unknown exception, the code should not be run to here, errorMessage: {0}", errorMessage)); }, retryTimes, true); }
public void Process(ProcessingEvent processingMessage) { var aggregateRootId = processingMessage.Message.AggregateRootId; if (string.IsNullOrEmpty(aggregateRootId)) { throw new ArgumentException("aggregateRootId of domain event stream cannot be null or empty, domainEventStreamId:" + processingMessage.Message.Id); } lock (_lockObj) { var mailbox = _mailboxDict.GetOrAdd(aggregateRootId, x => { var latestHandledEventVersion = GetAggregateRootLatestHandledEventVersion(processingMessage.Message.AggregateRootTypeName, aggregateRootId); return(new ProcessingEventMailBox(aggregateRootId, latestHandledEventVersion, y => DispatchProcessingMessageAsync(y, 0), _logger)); }); mailbox.EnqueueMessage(processingMessage); } }
/// <summary> /// Start /// </summary> /// <returns></returns> public DomainEventConsumer Start() { _sendReplyService.Start(); _consumer.OnMessageReceived += (sender, e) => { try { var message = _jsonSerializer.Deserialize <EventStreamMessage>(Encoding.UTF8.GetString(e.Context.GetBody())); var domainEventStreamMessage = ConvertToDomainEventStream(message); var processContext = new DomainEventStreamProcessContext(this, domainEventStreamMessage, e.Context); var processingMessage = new ProcessingEvent(domainEventStreamMessage, processContext); _logger.DebugFormat("ENode event stream message received, messageId: {0}, aggregateRootId: {1}, aggregateRootType: {2}, version: {3}", domainEventStreamMessage.Id, domainEventStreamMessage.AggregateRootId, domainEventStreamMessage.AggregateRootTypeName, domainEventStreamMessage.Version); _messageProcessor.Process(processingMessage); } catch (Exception ex) { _logger.Error($"ENode event stream message handle failed: {ex.Message}, eventStream: {Encoding.UTF8.GetString(e.Context.GetBody())}", ex); } }; _consumer.Start(); return(this); }
public void Process(ProcessingEvent processingMessage) { var aggregateRootId = processingMessage.Message.AggregateRootId; if (string.IsNullOrEmpty(aggregateRootId)) { throw new ArgumentException("aggregateRootId of domain event stream cannot be null or empty, domainEventStreamId:" + processingMessage.Message.Id); } var mailbox = _mailboxDict.GetOrAdd(aggregateRootId, x => new ProcessingEventMailBox(processingMessage.Message.AggregateRootTypeName, processingMessage.Message.AggregateRootId, y => DispatchProcessingMessageAsync(y, 0), _logger)); var mailboxTryUsingCount = 0L; while (!mailbox.TryUsing()) { Thread.Sleep(1); mailboxTryUsingCount++; if (mailboxTryUsingCount % 10000 == 0) { _logger.WarnFormat("Event mailbox try using count: {0}, aggregateRootId: {1}, aggregateRootTypeName: {2}", mailboxTryUsingCount, mailbox.AggregateRootId, mailbox.AggregateRootTypeName); } } if (mailbox.IsRemoved) { mailbox = _mailboxDict.GetOrAdd(aggregateRootId, x => new ProcessingEventMailBox(processingMessage.Message.AggregateRootTypeName, processingMessage.Message.AggregateRootId, y => DispatchProcessingMessageAsync(y, 0), _logger)); } ProcessingEventMailBox.EnqueueMessageResult enqueueResult = mailbox.EnqueueMessage(processingMessage); if (enqueueResult == ProcessingEventMailBox.EnqueueMessageResult.Ignored) { processingMessage.ProcessContext.NotifyEventProcessed(); } else if (enqueueResult == ProcessingEventMailBox.EnqueueMessageResult.AddToWaitingList) { AddToRefreshAggregateMailBoxToDict(mailbox); } mailbox.ExitUsing(); }
static void Main( string[] args ) { // Write program headers to the command line Console.WriteLine( "IDPickerReport " + Version + " (" + LastModified.ToShortDateString() + ")" ); Console.WriteLine( "IDPickerWorkspace " + Workspace.Version + " (" + Workspace.LastModified.ToShortDateString() + ")" ); Console.WriteLine( "IDPickerPresentation " + Presentation.Version + " (" + Presentation.LastModified.ToShortDateString() + ")" ); Console.WriteLine( IDPREPORT_LICENSE ); // Process the command line List<string> argsList = new List<string>( args ); if( InitProcess( ref argsList ) ) { return; } // Init the IDPicker workspace long start; Workspace ws = new Workspace( rtConfig ); ws.setStatusOutput( Console.Out ); // Initialize the modifications that can and can not appear in distinct peptides ws.distinctPeptideSettings = new Workspace.DistinctPeptideSettings( rtConfig.ModsAreDistinctByDefault, rtConfig.DistinctModsOverride, rtConfig.IndistinctModsOverride ); // Read the spectra export from a previous search, if given if( rtConfig.SpectraExport != string.Empty && rtConfig.SearchScoreNames != string.Empty ) { string[] scores = rtConfig.SearchScoreNames.Split( new char[] { ' ' } ); ws.spectraExport = new ImportSpectraExport( rtConfig.SpectraExport, scores ); } #region SNP Annotation stuff (TODO: simplify this logic, i.e. use a bool instead of testing for empty string) // Read the unimod modification database, if provided if( rtConfig.UnimodXMLPath != string.Empty ) { try { Console.WriteLine( "Reading modification annotations from unimod xml file path: " + rtConfig.UnimodXMLPath ); ws.readUniModXML( rtConfig.UnimodXMLPath ); Console.WriteLine( "Finished reading modification annotations." ); //ws.printUnimodObjects( 57.03f ); //Environment.Exit( 1 ); } catch( Exception e ) { Console.Error.WriteLine( e.StackTrace.ToString() ); Console.Error.WriteLine( "Error reading unimod xml at : " + rtConfig.UnimodXMLPath ); } } // Read the CanProVar database, if provided if( rtConfig.ProCanVarFasta != string.Empty && rtConfig.ProCanVarMap != string.Empty ) { Console.WriteLine( "Reading ProCanVar SNP data....." ); ws.snpAnntoations = new SNPMetaDataGenerator(); ws.snpAnntoations.getVariantDataFromProCanVarFlatFile( rtConfig.ProCanVarFasta, rtConfig.ProCanVarMap ); Console.WriteLine( "Finished reading ProCanVar SNP data." ); /*SNPMetaDataGenerator snpData = new SNPMetaDataGenerator(); snpData.getVariantDataFromProCanVarFlatFile( rtConfig.ProCanVarFasta, rtConfig.ProCanVarMap ); Console.WriteLine( "Finished reading ProCanVar SNP data." ); SNPMetaDataGenerator.SNP test = new SNPMetaDataGenerator.SNP( "Y", "H", "24" ); string str = snpData.getSNPAnnotationFromProCanVar( "ENSP00000368054", test, "EGFYAVVIFLSIFVIIVTCLMILYR" ); Console.WriteLine( str ); Environment.Exit( 1 );*/ } #endregion #region Read input idpXML files List<string> inputFilepaths = new List<string>(); for( int i = 1; i < argsList.Count; ++i ) { try { string path = Path.GetDirectoryName(argsList[i]); if (path.Length < 1) { path = "." + Path.DirectorySeparatorChar; } //Console.WriteLine( path + " : " + Path.GetFileName( args[i] ) ); inputFilepaths.AddRange(Directory.GetFiles(path, Path.GetFileName(argsList[i]))); foreach( string inputFilepath in inputFilepaths ) { try { if( !Util.TestFileType( inputFilepath, "idpickerpeptides" ) ) continue; start = DateTime.Now.Ticks; Console.WriteLine( "Reading and parsing IDPicker XML from filepath: " + inputFilepath ); StreamReader inputStream = new StreamReader( inputFilepath ); // Read each file and assign them to the root group. ws.readPeptidesXml( inputStream, "", rtConfig.MaxFDR, rtConfig.MaxResultRank ); inputStream.Close(); Console.WriteLine( "\nFinished reading and parsing IDPicker XML; " + new TimeSpan( DateTime.Now.Ticks - start ).TotalSeconds + " seconds elapsed." ); } catch( Exception e ) { Console.Error.WriteLine( e.StackTrace.ToString() ); Console.Error.WriteLine( "Error reading input filepath \"" + inputFilepath + "\": " + e.Message ); continue; } } } catch( Exception e ) { Console.Error.WriteLine( "Error parsing input filemask \"" + argsList[i] + "\": " + e.Message ); continue; } } if( ws.groups.Count == 0 ) { Console.Error.WriteLine( "Error: no input files read; nothing to report." ); return; } #endregion // Generate a processing event for the idpReport. ProcessingEvent presentationEvent = new ProcessingEvent(); presentationEvent.type = "presentation/filtration"; presentationEvent.startTime = DateTime.Now; ProcessingParam presentationParam = new ProcessingParam(); presentationParam.name = "software name"; presentationParam.value = "idpReport"; presentationEvent.parameters.Add( presentationParam ); presentationParam = new ProcessingParam(); presentationParam.name = "software version"; presentationParam.value = Version + " (" + LastModified.ToShortDateString() + ")"; presentationEvent.parameters.Add( presentationParam ); RunTimeVariableMap presentationVars = rtConfig.getVariables(); foreach( KeyValuePair<string, string> itr in presentationVars ) { presentationParam = new ProcessingParam(); presentationParam.name = itr.Key; presentationParam.value = itr.Value; presentationEvent.parameters.Add( presentationParam ); } #region Pre-filtering validation { ws.validate( rtConfig.MaxFDR, 0, 100 ); } #endregion #region Apply filtering criteria and assemble proteins start = DateTime.Now.Ticks; Console.WriteLine( "Filtering out peptides shorter than " + rtConfig.MinPeptideLength + " residues..." ); ws.filterByMinimumPeptideLength( rtConfig.MinPeptideLength ); Console.WriteLine( "\nFinished filtering by minimum peptide length; " + new TimeSpan( DateTime.Now.Ticks - start ).TotalSeconds + " seconds elapsed." ); { ws.validate( rtConfig.MaxFDR, 0, 100 ); } start = DateTime.Now.Ticks; Console.WriteLine( "Filtering out results with more than " + rtConfig.MaxAmbiguousIds + " ambiguous ids..." ); ws.filterByResultAmbiguity( rtConfig.MaxAmbiguousIds ); Console.WriteLine( "\nFinished filtering by maximum ambiguous ids; " + new TimeSpan( DateTime.Now.Ticks - start ).TotalSeconds + " seconds elapsed." ); { ws.validate( rtConfig.MaxFDR, 0, rtConfig.MaxAmbiguousIds ); } start = DateTime.Now.Ticks; Console.WriteLine( "Filtering out proteins with less than " + rtConfig.MinDistinctPeptides + " distinct peptides..." ); ws.filterByDistinctPeptides( rtConfig.MinDistinctPeptides ); Console.WriteLine( "\nFinished filtering by minimum distinct peptides; " + new TimeSpan( DateTime.Now.Ticks - start ).TotalSeconds + " seconds elapsed." ); { ws.validate( rtConfig.MaxFDR, rtConfig.MinDistinctPeptides, rtConfig.MaxAmbiguousIds ); } start = DateTime.Now.Ticks; Console.WriteLine( "Filtering out proteins with less than " + rtConfig.MinSpectraPerProtein + " spectra..." ); ws.filterBySpectralCount( rtConfig.MinSpectraPerProtein ); Console.WriteLine( "\nFinished filtering by minimum protein spectral counts; " + new TimeSpan( DateTime.Now.Ticks - start ).TotalSeconds + " seconds elapsed." ); { ws.validate( rtConfig.MaxFDR, rtConfig.MinDistinctPeptides, rtConfig.MaxAmbiguousIds ); } start = DateTime.Now.Ticks; Console.WriteLine( "Assembling protein groups..." ); ws.assembleProteinGroups(); Console.WriteLine( "\nFinished assembling protein groups; " + new TimeSpan( DateTime.Now.Ticks - start ).TotalSeconds + " seconds elapsed." ); { ws.validate( rtConfig.MaxFDR, rtConfig.MinDistinctPeptides, rtConfig.MaxAmbiguousIds ); } start = DateTime.Now.Ticks; Console.WriteLine( "Assembling peptide groups..." ); ws.assemblePeptideGroups(); Console.WriteLine( "\nFinished assembling peptide groups; " + new TimeSpan( DateTime.Now.Ticks - start ).TotalSeconds + " seconds elapsed." ); { ws.validate( rtConfig.MaxFDR, rtConfig.MinDistinctPeptides, rtConfig.MaxAmbiguousIds ); } start = DateTime.Now.Ticks; Console.WriteLine( "Assembling clusters..." ); ws.assembleClusters(); Console.WriteLine( "\nFinished assembling clusters; " + new TimeSpan( DateTime.Now.Ticks - start ).TotalSeconds + " seconds elapsed." ); { ws.validate( rtConfig.MaxFDR, rtConfig.MinDistinctPeptides, rtConfig.MaxAmbiguousIds ); } start = DateTime.Now.Ticks; // Determine the minimum number of protein clusters needed // to explain all the peptides. Console.WriteLine( "Assembling minimum covering set for clusters..." ); int clusterCount = 0; foreach( ClusterInfo c in ws.clusters ) { ++clusterCount; Console.Write( "Assembling minimum covering set for cluster " + clusterCount + " of " + ws.clusters.Count + " (" + c.proteinGroups.Count + " protein groups, " + c.results.Count + " results) \r" ); ws.assembleMinimumCoveringSet( c ); } Console.WriteLine( "\nFinished assembling minimum covering sets; " + new TimeSpan( DateTime.Now.Ticks - start ).TotalSeconds + " seconds elapsed." ); { ws.validate( rtConfig.MaxFDR, rtConfig.MinDistinctPeptides, rtConfig.MaxAmbiguousIds ); } if( rtConfig.MinAdditionalPeptides > 0 ) { start = DateTime.Now.Ticks; Console.WriteLine( "Filtering workspace by minimum covering set..." ); ws.filterByMinimumCoveringSet( rtConfig.MinAdditionalPeptides ); Console.WriteLine( "\nFinished filtering by minimum covering set; " + new TimeSpan( DateTime.Now.Ticks - start ).TotalSeconds + " seconds elapsed." ); { ws.validate( rtConfig.MaxFDR, rtConfig.MinDistinctPeptides, rtConfig.MaxAmbiguousIds ); } } start = DateTime.Now.Ticks; Console.Write( "Assembling source groups..." ); ws.assembleSourceGroups(); Console.WriteLine( " finished; " + new TimeSpan( DateTime.Now.Ticks - start ).TotalSeconds + " seconds elapsed." ); #endregion #region Post-filtering validation // Check to see if the protein, peptides, sources, and the clusters have // all required fields and satisfy the user-defined criteria. try { ws.validate( rtConfig.MaxFDR, rtConfig.MinDistinctPeptides, rtConfig.MaxAmbiguousIds ); } catch( Exception e ) { Console.Error.WriteLine( "Error while validating workspace: " + e.Message ); return; } #endregion #region SNP annotation stuff (TODO: move this into a Workspace function) if( rtConfig.FlagUnknownMods.Length > 0 ) { string[] toks = rtConfig.FlagUnknownMods.Split( new char[] { ' ' } ); if( toks.Length % 2 == 0 ) { ws.knownModMasses = new float[toks.Length / 2]; ws.knownModResidues = new char[toks.Length / 2]; int index = 0; for( int i = 0; i < toks.Length - 1; i = i + 2 ) { ws.knownModResidues[index] = toks[i][0]; ws.knownModMasses[index] = (float) Convert.ToDouble( toks[i + 1] ); ++index; } } } // If the user wants to annotate the SNPs found in the // dataset then pull the annotations. if( rtConfig.AnnotateSNPs.Length > 0 ) { ws.pullSNPMetaData( rtConfig.AnnotateSNPs ); } #endregion // Make an output folder and generate files Console.WriteLine( "Creating output directory for report: " + rtConfig.outputDir ); if( !Directory.Exists( rtConfig.outputDir ) ) Directory.CreateDirectory( rtConfig.outputDir ); Directory.SetCurrentDirectory( rtConfig.outputDir ); StreamWriter outputStream; #region Web report if( rtConfig.OutputWebReport ) { string reportIndexFilename = "index.html"; string idpickerJavascriptFilename = "idpicker-scripts.js"; string idpickerStylesheetFilename = "idpicker-style.css"; string navFrameFilename = rtConfig.outputPrefix + "-nav.html"; string wsSummaryFilename = rtConfig.outputPrefix + "-summary.html"; string wsDataProcessingDetailsFilename = rtConfig.outputPrefix + "-processing.html"; string wsIndexByProteinFilename = rtConfig.outputPrefix + "-index-by-protein.html"; string wsIndexBySpectrumFilename = rtConfig.outputPrefix + "-index-by-spectrum.html"; string wsIndexByModificationFilename = rtConfig.outputPrefix + "-index-by-modification.html"; string wsGroupsFilename = rtConfig.outputPrefix + "-groups.html"; string wsSequencesPerProteinByGroupFilename = rtConfig.outputPrefix + "-sequences-per-protein-by-group.html"; string wsSpectraPerProteinByGroupFilename = rtConfig.outputPrefix + "-spectra-per-protein-by-group.html"; string wsSpectraPerPeptideByGroupFilename = rtConfig.outputPrefix + "-spectra-per-peptide-by-group.html"; try { Console.WriteLine( "Writing report index: " + reportIndexFilename ); outputStream = new StreamWriter( reportIndexFilename ); outputStream.Write( Presentation.assembleReportIndex( rtConfig.outputPrefix, navFrameFilename, wsSummaryFilename ) ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError report index: " + e.Message ); } try { Console.WriteLine( "Writing javascript: " + idpickerJavascriptFilename ); outputStream = new StreamWriter( idpickerJavascriptFilename ); outputStream.Write( Presentation.assembleJavascript() ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing javascript: " + e.Message ); } try { Console.WriteLine( "Writing stylesheet: " + idpickerStylesheetFilename ); outputStream = new StreamWriter( idpickerStylesheetFilename ); outputStream.Write( Presentation.assembleStylesheet() ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing stylesheet: " + e.Message ); } try { Console.WriteLine( "Writing navigation frame: " + navFrameFilename ); Dictionary<string, string> navigationMap = new Dictionary<string, string>(); navigationMap.Add( "Summary", wsSummaryFilename ); navigationMap.Add( "Group association table", wsGroupsFilename ); navigationMap.Add( "Index by protein", wsIndexByProteinFilename ); navigationMap.Add( "Index by spectrum", wsIndexBySpectrumFilename ); navigationMap.Add( "Index by modification", wsIndexByModificationFilename ); navigationMap.Add( "Sequences per protein by group", wsSequencesPerProteinByGroupFilename ); navigationMap.Add( "Spectra per protein by group", wsSpectraPerProteinByGroupFilename ); navigationMap.Add( "Spectra per peptide by group", wsSpectraPerPeptideByGroupFilename ); navigationMap.Add( "Data processing details", wsDataProcessingDetailsFilename ); outputStream = new StreamWriter( navFrameFilename ); Presentation.assembleNavFrameHtml( ws, outputStream, rtConfig.outputPrefix, navigationMap ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing navigation frame: " + e.Message ); } try { Console.WriteLine( "Writing index by protein to filepath: " + wsIndexByProteinFilename ); outputStream = new StreamWriter( wsIndexByProteinFilename ); Presentation.assembleIndexByProteinHtml( ws, outputStream, rtConfig.outputPrefix ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing index by protein: " + e.Message ); } try { Console.WriteLine( "Writing index by spectrum to filepath: " + wsIndexBySpectrumFilename ); outputStream = new StreamWriter( wsIndexBySpectrumFilename ); Presentation.assembleIndexBySpectrumHtml( ws, outputStream, rtConfig.outputPrefix, rtConfig.AllowSharedSourceNames ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing index by spectrum: " + e.Message ); } try { Console.WriteLine( "Writing index by modification to filepath: " + wsIndexByModificationFilename ); outputStream = new StreamWriter( wsIndexByModificationFilename ); Presentation.assembleIndexByModificationHtml( ws, outputStream, rtConfig.outputPrefix ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing index by modification: " + e.Message ); } try { Console.WriteLine( "Writing overall summary to filepath: " + wsSummaryFilename ); outputStream = new StreamWriter( wsSummaryFilename ); Dictionary<string, string> parameterMap = new Dictionary<string, string>(); parameterMap.Add( "Maximum FDR", rtConfig.MaxFDR.ToString( "f2" ) ); parameterMap.Add( "Minimum distinct peptides", rtConfig.MinDistinctPeptides.ToString() ); parameterMap.Add( "Maximum ambiguous IDs", rtConfig.MaxAmbiguousIds.ToString() ); parameterMap.Add( "Minimum peptide length", rtConfig.MinPeptideLength.ToString() ); parameterMap.Add( "Minimum additional peptides", rtConfig.MinAdditionalPeptides.ToString() ); parameterMap.Add( "Minimum spectra per protein", rtConfig.MinSpectraPerProtein.ToString() ); if( rtConfig.ModsAreDistinctByDefault ) parameterMap.Add( "Indistinct modifications", rtConfig.IndistinctModsOverride ); else parameterMap.Add( "Distinct modifications", rtConfig.DistinctModsOverride ); Presentation.assembleSummaryHtml( ws, outputStream, rtConfig.outputPrefix, parameterMap ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing overall summary: " + e.Message ); } presentationEvent.endTime = DateTime.Now; foreach( SourceInfo source in ws.groups["/"].getSources( true ) ) source.processingEvents.Add( presentationEvent ); try { Console.WriteLine( "Writing data processing details to filepath: " + wsDataProcessingDetailsFilename ); outputStream = new StreamWriter( wsDataProcessingDetailsFilename ); Presentation.assembleDataProcessingDetailsHtml( ws, outputStream, rtConfig.outputPrefix ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing data processing details: " + e.Message ); } try { Console.WriteLine( "Writing source groups summary to filepath: " + wsGroupsFilename ); outputStream = new StreamWriter( wsGroupsFilename ); Presentation.assembleGroupAssociationHtml( ws, outputStream, rtConfig.outputPrefix ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing source groups summary: " + e.Message ); } Console.WriteLine( "Writing sequences per protein table to filepath: " + wsSequencesPerProteinByGroupFilename ); try { outputStream = new StreamWriter( wsSequencesPerProteinByGroupFilename ); Presentation.assembleProteinSequencesTable( ws, outputStream, rtConfig.outputPrefix ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing sequences per protein table: " + e.Message ); } try { Console.WriteLine( "Writing spectra per protein table to filepath: " + wsSpectraPerProteinByGroupFilename ); outputStream = new StreamWriter( wsSpectraPerProteinByGroupFilename ); Presentation.assembleProteinSpectraTable( ws, outputStream, rtConfig.outputPrefix ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing spectra per protein table: " + e.Message ); } try { Console.WriteLine( "Writing spectra per peptide table to filepath: " + wsSpectraPerPeptideByGroupFilename ); outputStream = new StreamWriter( wsSpectraPerPeptideByGroupFilename ); Presentation.assemblePeptideSpectraTable( ws, outputStream, rtConfig.outputPrefix ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing spectra per peptide table: " + e.Message ); } for( int i = 0; i < ws.clusters.Count; ++i ) { int cid = i + 1; string clusterSummaryFilename = rtConfig.outputPrefix + "-cluster" + cid + ".html"; try { Console.Write( "Writing summary for cluster " + cid + " of " + ws.clusters.Count + " to filepath: " + clusterSummaryFilename + " \r" ); outputStream = new StreamWriter( clusterSummaryFilename ); Presentation.assembleClusterHtml( ws, outputStream, rtConfig.outputPrefix, i, rtConfig.GenerateBipartiteGraphs, rtConfig.RawSourceHostURL, rtConfig.RawSourcePath, rtConfig.RawSourceExtension ); outputStream.Close(); } catch( System.Exception e ) { Console.Error.WriteLine( "\nError writing summary for cluster " + cid + ": " + e.Message ); } } Console.WriteLine(); } #endregion #region Generate GraphViz files /*outputStream = new StreamWriter( "workspace.dot" ); outputStream.Write( assembleWorkspaceGraph( ws ) ); outputStream.Close();*/ if( rtConfig.GenerateBipartiteGraphs ) { for( int i = 0; i < ws.clusters.Count; ++i ) { int cid = i + 1; string clusterGraphTextFilename = rtConfig.outputPrefix + "-cluster" + cid + ".dot"; Console.Write( "Writing graph of cluster " + cid + " of " + ws.clusters.Count + " to filepath: " + clusterGraphTextFilename + " \r" ); outputStream = new StreamWriter( clusterGraphTextFilename ); Presentation.assembleClusterGraph( ws, outputStream, i ); outputStream.Close(); } Console.WriteLine(); for( int i = 0; i < ws.clusters.Count; ++i ) { int cid = i + 1; string clusterGraphTextFilename = rtConfig.outputPrefix + "-cluster" + cid + ".dot"; string clusterGraphImageFilename = rtConfig.outputPrefix + "-cluster" + cid + ".gif"; Console.Write( "Graphing cluster " + cid + " of " + ws.clusters.Count + " from filepath: " + clusterGraphTextFilename + " \r" ); string dotCommand = "dot"; string dotArgs = "-Tgif -o" + clusterGraphImageFilename + " " + clusterGraphTextFilename; Process dotProcess = new Process(); dotProcess.StartInfo.FileName = dotCommand; dotProcess.StartInfo.Arguments = dotArgs; dotProcess.StartInfo.CreateNoWindow = true; dotProcess.StartInfo.UseShellExecute = false; dotProcess.Start(); dotProcess.WaitForExit(); //File.Delete( clusterGraphTextFilename ); } Console.WriteLine(); } #endregion #region Text report if( rtConfig.OutputTextReport ) { string wsSummaryFilename = rtConfig.outputPrefix + "-summary.tsv"; string wsSequencesPerProteinByGroupFilename = rtConfig.outputPrefix + "-sequences-per-protein-by-group.tsv"; string wsSpectraPerProteinByGroupFilename = rtConfig.outputPrefix + "-spectra-per-protein-by-group.tsv"; string wsSpectraPerPeptideByGroupFilename = rtConfig.outputPrefix + "-spectra-per-peptide-by-group.tsv"; string wsSpectraTableFilename = rtConfig.outputPrefix + "-spectra-table.tsv"; string wsProteinGroupToPeptideGroupFilename = rtConfig.outputPrefix + "-protein-to-peptide-table.tsv"; string wsSpectraPerPeptideGroupFilename = rtConfig.outputPrefix + "-spectra-per-peptide-group.tsv"; // Write a protein modification report. This report takes all the modifications // seen in the dataset and writes out a tab-delimited file of each modification // and the samples it was identified /*try { string modificationTableFilename = rtConfig.outputPrefix + "-prot-modification-table.csv"; Console.WriteLine( "Writing protein modification report to filepath: " + modificationTableFilename ); outputStream = new StreamWriter( modificationTableFilename ); outputStream.Write( Presentation.assembleDetailedModificationReport( ws ) ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing protein modification report: " + e.Message ); }*/ string rootInputDirectory; Util.LongestCommonPrefix(inputFilepaths, out rootInputDirectory); if (String.IsNullOrEmpty(rootInputDirectory)) rootInputDirectory = Directory.GetCurrentDirectory(); else if (!Directory.Exists(rootInputDirectory)) rootInputDirectory = Path.GetDirectoryName(rootInputDirectory); QuantifyingTransmogrifier.quantify(ws, rootInputDirectory, rtConfig.quantitationMethod); try { Console.WriteLine( "Writing overall summary to filepath: " + wsSummaryFilename ); outputStream = new StreamWriter( wsSummaryFilename ); Presentation.exportSummaryTable( ws, outputStream, rtConfig.outputPrefix, '\t' ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing overall summary: " + e.Message ); } Console.WriteLine( "Writing sequences per protein table to filepath: " + wsSequencesPerProteinByGroupFilename ); try { outputStream = new StreamWriter( wsSequencesPerProteinByGroupFilename ); Presentation.exportProteinSequencesTable( ws, outputStream, rtConfig.outputPrefix, '\t' ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing sequences per protein table: " + e.Message ); } try { Console.WriteLine( "Writing spectra per protein table to filepath: " + wsSpectraPerProteinByGroupFilename ); outputStream = new StreamWriter( wsSpectraPerProteinByGroupFilename ); Presentation.exportProteinSpectraTable( ws, outputStream, rtConfig.outputPrefix, '\t' ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing spectra per protein table: " + e.Message ); } try { Console.WriteLine( "Writing spectra per peptide table to filepath: " + wsSpectraPerPeptideByGroupFilename ); outputStream = new StreamWriter( wsSpectraPerPeptideByGroupFilename ); Presentation.exportPeptideSpectraTable(ws, outputStream, rtConfig.outputPrefix, rtConfig.quantitationMethod, '\t'); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing spectra per peptide table: " + e.Message ); } try { Console.WriteLine( "Writing spectra table to filepath: " + wsSpectraTableFilename ); outputStream = new StreamWriter( wsSpectraTableFilename ); Presentation.exportSpectraTable( ws, outputStream, rtConfig.outputPrefix, rtConfig.quantitationMethod, '\t' ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError writing spectra table: " + e.Message ); } try { Console.WriteLine( "Writing protein group to peptide group table to filepath: " + wsProteinGroupToPeptideGroupFilename ); outputStream = new StreamWriter( wsProteinGroupToPeptideGroupFilename ); Presentation.exportProteinGroupToPeptideGroupTable( ws, outputStream, '\t' ); outputStream.Close(); } catch( Exception e ) { Console.Error.WriteLine( "\nError protein group to peptide group table: " + e.Message ); } try { Console.WriteLine( "Writing spectra per peptide group table to filepath: " + wsSpectraPerPeptideGroupFilename ); outputStream = new StreamWriter(wsSpectraPerPeptideGroupFilename); Presentation.exportPeptideGroupSpectraTable(ws, outputStream, rtConfig.outputPrefix, rtConfig.quantitationMethod, '\t'); outputStream.Close(); } catch (Exception e) { Console.Error.WriteLine( "\nError spectra per peptide group table: " + e.Message ); } } #endregion #region Xml report if( rtConfig.OutputXmlReport ) { string wsAssembledXmlFilename = rtConfig.outputPrefix + "-assembled.idpXML"; outputStream = new StreamWriter( wsAssembledXmlFilename ); ws.assemblePeptidesXmlToStream( outputStream ); outputStream.Close(); } #endregion }
/// <summary> Update UI </summary> /// <param name="text">Step name</param> public static void LaunchProcessingEvent(string text) => ProcessingEvent?.Invoke(text);
private ProcessingEventMailBox BuildProcessingEventMailBox(ProcessingEvent processingMessage) { var latestHandledEventVersion = GetAggregateRootLatestHandledEventVersion(processingMessage.Message.AggregateRootTypeName, processingMessage.Message.AggregateRootId); return(new ProcessingEventMailBox(processingMessage.Message.AggregateRootTypeName, processingMessage.Message.AggregateRootId, latestHandledEventVersion + 1, y => DispatchProcessingMessageAsync(y, 0), _logger)); }
/// <summary> /// Use this attribute to denote the method is to be attached to all instances of a given test class level. Either at the step response, response element, or expected response levels. /// </summary> /// <param name="processingEvent">event type to attach the delegate to</param> public ResponseProcessingAttribute(ProcessingEvent processingEvent) { Initialize(processingEvent, "", "", -1, -1, -1); }
/// <summary> /// Update UI /// </summary> /// <param name="text">Message text</param> /// <param name="progressAmount">Progress amount</param> private void LaunchProcessingEvent(string text, int progressAmount) { ProcessingEvent?.Invoke(text, progressAmount); }
/// <summary> Update UI </summary> /// <param name="text">Step name</param> private void LaunchProcessingEvent(string text) => ProcessingEvent?.Invoke(text);