public override GenericFastqInputs perform(GenericFastqInputs inputs) { SequencerDecisionTree decTree = new SequencerDecisionTree(inputs.FastqFile); inputs.FastqFile.Tests(); return(inputs); }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { List <FqSequence> foundSequences = inputs.FastqFile.findSequence(inputs.NucleotideSequence); FastqController.getInstance().GetFqFileMap().AddSequenceQueryResults(foundSequences); return(inputs); }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { inputs.FastqFile.cleanStarts(inputs.NucleotidesToClean); inputs.FastqFile.cleanEnds(inputs.NucleotidesToClean); inputs.FastqFile.Tests(); return(inputs); }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { SequencerDecisionTree decTree = new SequencerDecisionTree(inputs.FastqFile); inputs.FastqFile.Tests(); return inputs; }
/// <summary> /// Updates the GUI. Calls the richText_Display and FastqGUI_Charts classes to update the information contained within them. /// </summary> /// <param name="newFqFile"></param> public void UpdateGUI(GenericFastqInputs input) { Console.WriteLine("Total Memory Allocated: {0}", HelperMethods.ConvertBytesToMegabytes(GC.GetTotalMemory(false))); ResetChartsSelectors(); drawChart(FastqController.getInstance().GetFqFileMap().GlobalDetails, FastqGUI_Charts.FastqChartTypes.Distribution.ToString()); display.Update(input, richText_Display); }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { inputs.FastqFile.cleanStarts(inputs.NucleotidesToClean); inputs.FastqFile.cleanEnds(inputs.NucleotidesToClean); inputs.FastqFile.Tests(); return inputs; }
/// <summary> /// Method responds to button clicks on the "remove sequences > with failed reads" menu item. It hands the task to the controller for /// processing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void withFailedReadsToolStripMenuItem_Click(object sender, EventArgs e) { if (FastqController.getInstance().fqFileMap != null && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY) { GenericFastqInputs inputs = new GenericFastqInputs(); inputs.TaskAction = Task_RemoveMisSeqeuence.statement; FastqController.getInstance().InitializeAction(inputs); } }
/// <summary> /// Method updates the GUI when on this thread or calls an invoke upon it for instances when called from non /// COM thread. Ensures that alterations that occur within the GUI occur within its on thread model. /// </summary> /// <param name="newFqFile"></param> public void UpdateGUIThread(GenericFastqInputs input) { if (this.InvokeRequired) { this.BeginInvoke(new UpdateFastqGUI(UpdateGUIThread), new object[] { input }); return; } UpdateGUI(input); }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { if (Preferences.getInstance().getSeqDecisionMethod()) { SequencerDetermination seqDetermine = new SequencerDetermination(inputs.FastqFile); } else if (!Preferences.getInstance().getSeqDecisionMethod()) { SequencerDecisionTree decTree = new SequencerDecisionTree(inputs.FastqFile); } return inputs; }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { writer = inputs.SaveStreamWriter; FqFile_Component component = (FqFile_Component) inputs.FastqFile; for (int i = 0; i < component.getFastqArraySize(); i++) { writer.Write(component.getFastqSequenceByPosition(i).createFastqBlock(component.getMap())); } return inputs; }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { if (Preferences.getInstance().getSeqDecisionMethod()) { SequencerDetermination seqDetermine = new SequencerDetermination(inputs.FastqFile); } else if (!Preferences.getInstance().getSeqDecisionMethod()) { SequencerDecisionTree decTree = new SequencerDecisionTree(inputs.FastqFile); } return(inputs); }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { writer = inputs.SaveStreamWriter; FqFile_Component component = (FqFile_Component)inputs.FastqFile; for (int i = 0; i < component.getFastqArraySize(); i++) { writer.Write(component.getFastqSequenceByPosition(i).createFastqBlock(component.getMap())); } return(inputs); }
/// <summary> /// Entry point for the thread, allows controller to create unified method signature for the PerformAction method. /// Method checks threads state and hands of to PerformAction. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void RunTask(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; GenericFastqInputs input = (GenericFastqInputs)e.Argument; if ((worker.CancellationPending == true)) { e.Cancel = true; } else { PerformAction(worker, input); } }
/// <summary> /// Method responds to button clicks on the find sequences tool strip menu iteam and then hands details to controller for processing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void findSequenceToolStripMenuItem_Click(object sender, EventArgs e) { if (FastqController.getInstance().fqFileMap != null && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY) { InputBoxResult result = InputBox.Show("Enter a sequence you wish to find:", "Find Sequence", "", new InputBoxValidatingHandler(inputBox_SequenceValidating)); if (result.OK) { GenericFastqInputs inputs = new GenericFastqInputs(); inputs.NucleotideSequence = result.Text.Trim(); inputs.TaskAction = Task_FindSequences.statement; FastqController.getInstance().GetFqFileMap().InitializeNewSequenceSearchList(); FastqController.getInstance().InitializeAction(inputs); } } }
/// <summary> /// Method responds to button clicks on the tail clean tool strip menu item. It obtains int for nucleotides to clean /// from sequences and hands to controller for processing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cleanTailsToolStripMenuItem_Click(object sender, EventArgs e) { if (FastqController.getInstance().fqFileMap != null && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY) { InputBoxResult result = InputBox.Show("Enter a number of nucleotides to clean from tails:", "Clean Sequence Tails", "", new InputBoxValidatingHandler(inputBox_Validating)); if (result.OK) { if (HelperMethods.safeParseInt(result.Text.Trim()) == true) { GenericFastqInputs inputs = new GenericFastqInputs(); inputs.NucleotidesToClean = Int32.Parse(result.Text.Trim()); inputs.TaskAction = Task_TailCleanTask.statement; FastqController.getInstance().InitializeAction(inputs); } } } }
private void belowLengthToolStripMenuItem_Click(object sender, EventArgs e) { if (FastqController.getInstance().fqFileMap != null && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY) { InputBoxResult result = InputBox.Show("Remove Sequences Below Threshold: ", "Remove Sequences", "", new InputBoxValidatingHandler(inputBox_SequenceLengthThresholdValidating)); if (result.OK) { if (HelperMethods.safeParseInt(result.Text.Trim()) == true) { GenericFastqInputs inputs = new GenericFastqInputs(); inputs.LengthThreshold = Int32.Parse(result.Text.Trim()); inputs.TaskAction = Task_RemoveSequencesBelowLength.statement; FastqController.getInstance().InitializeAction(inputs); } } } }
/// <summary> /// Key method in the display class, makes a decision on what to output based on the previous active task from the generic /// inputs transport class. Also accepts instance of the richtextbox which will display the output. /// </summary> /// <param name="input">Instance of the transport class. Used in this instance to inform the display class of previous activity</param> /// <param name="textBox">The rich text box that will display the outputs</param> public void Update(GenericFastqInputs input, RichTextBox textBox) { this.fqMap = FastqController.getInstance().GetFqFileMap(); this.textBox = textBox; if (input.TaskAction == Task_FindSequences.statement) { AddFoundSequenceData(); } else { ClearText(); DisplayFileDetails(); DisplayFastqFileDetails(); DisplayComponentDetais(); } }
/// <summary> /// Responds to button click on the Save CSV Menu Item, opens dialogue to select filename and then passes details to the /// controller class for processing. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void saveCSVDataToolStripMenuItem_Click(object sender, EventArgs e) { if (FastqController.getInstance().fqFileMap != null && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY) { SaveFileDialog save = new SaveFileDialog(); save.Filter = "CSV File|*.csv|Text File|*.txt"; save.Title = "Save CSV File"; if (save.ShowDialog() == DialogResult.OK) { String fileName = save.FileName; GenericFastqInputs inputs = new GenericFastqInputs(); inputs.SaveFileName = fileName; inputs.TaskAction = Task_SaveCSV.statement; FastqController.getInstance().InitializeAction(inputs); } } }
/// <summary> /// First point of call for the creation of a task within this class. Checks controller state is ready, then builds /// a background worker thread for tasks and launches thread. /// </summary> /// <param name="genericInputs">Input details that are necessary within the task, including potential file components</param> public void InitializeAction(GenericFastqInputs genericInputs) { if (fqFileMap != null && CONTROLLER_STATE == FastqControllerState.STATE_READY) { BackgroundWorker taskWorker = new BackgroundWorker(); taskWorker.WorkerReportsProgress = true; taskWorker.WorkerSupportsCancellation = true; taskWorker.DoWork += new DoWorkEventHandler(RunTask); taskWorker.ProgressChanged += new ProgressChangedEventHandler(observer.loadWorker_ProgressChanged); taskWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(observer.loadWorker_Completed); if (taskWorker.IsBusy != true) { taskWorker.RunWorkerAsync(genericInputs); } } }
/// <summary> /// Responds to button click on the Save Fastq Menu Item, opens dialogue to select filename and then passes details to the /// controller class for processing. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void saveFastqToolStripMenuItem_Click(object sender, EventArgs e) { if (FastqController.getInstance().fqFileMap != null && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY) { SaveFileDialog save = new SaveFileDialog(); save.Filter = FILE_DIALOGUE_FILTER; save.Title = "Save Fastq File"; if (save.ShowDialog() == DialogResult.OK) { String fileName = save.FileName; GenericFastqInputs inputs = new GenericFastqInputs(); inputs.SaveFileName = fileName; inputs.InitializeStreamWriter(fileName); inputs.TaskAction = Task_SaveFastq.statement; FastqController.getInstance().InitializeAction(inputs); } } }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { StreamWriter writer; String extension = Path.GetExtension(inputs.SaveFileName); String fileName = Path.GetFileNameWithoutExtension(inputs.SaveFileName); String[] part = Path.GetFileNameWithoutExtension(inputs.FastqFile.getFileName()).Split('_'); String directory = Path.GetDirectoryName(inputs.SaveFileName); String number = part[part.Length - 1]; String FullName = String.Format(@"{0}{1}{2}_{3}{4}", directory, Path.DirectorySeparatorChar, fileName, number, extension); string COMMA_DELIMITER = ","; string[] output; IFqFile fqFile = inputs.FastqFile; writer = new StreamWriter(FullName); output = new string[] { "Sequence Index", "Header", "Total Nucleotides", "G Count", "C Count", "Misread Count", "Lower Threshold", "First Quartile", "Median", "Mean", "Third Quartile", "Upper Threshold" }; writer.WriteLine(string.Join(COMMA_DELIMITER, output)); for (int i = 0; i < fqFile.getFastqArraySize(); i++) { FqSequence fqSeq = fqFile.getFastqSequenceByPosition(i); output = new string[] { fqSeq.getSeqIndex().ToString(), fqSeq.getSequenceHeader(), fqSeq.getFastqSeqSize().ToString(), fqSeq.getGCount().ToString(), fqSeq.getCCount().ToString(), fqSeq.getNCount().ToString(), fqSeq.getLowerThreshold().ToString(), fqSeq.getFirstQuartile().ToString(), fqSeq.getMedian().ToString(), fqSeq.getMean().ToString(), fqSeq.getThirdQuartile().ToString(), fqSeq.getUpperThreshold().ToString(), fqSeq.createSequenceString(fqFile.getMap()) }; writer.WriteLine(string.Join(COMMA_DELIMITER, output)); } Console.WriteLine("Saving CSV TO: {0}", FullName); writer.Flush(); writer.Close(); return(inputs); }
public GenericFastqInputs cleanAdapters(List <Adapters.Adapter> adapters, Dictionary <int, FqNucleotideRead> map) { String sequence = createSequenceString(map); GenericFastqInputs removedAdapter = null; foreach (Adapters.Adapter adapter in adapters) { Match match = Regex.Match(adapter.AdapterSequence, sequence.ToUpper(), RegexOptions.IgnoreCase); { if (match.Success) { int key = match.Groups[1].Index; cleanEnds(index - key); removedAdapter = new GenericFastqInputs(); removedAdapter.AdapterName = adapter.AdapterName; removedAdapter.SequenceIndex = SequenceIndex; InfoLine = InfoLine + "||Removed Adapter:" + adapter.AdapterName; } } } return(removedAdapter); }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { StreamWriter writer; String extension = Path.GetExtension(inputs.SaveFileName); String fileName = Path.GetFileNameWithoutExtension(inputs.SaveFileName); String[] part = Path.GetFileNameWithoutExtension(inputs.FastqFile.getFileName()).Split('_'); String directory = Path.GetDirectoryName(inputs.SaveFileName); String number = part[part.Length - 1]; String FullName = String.Format(@"{0}{1}{2}_{3}{4}", directory, Path.DirectorySeparatorChar, fileName, number, extension); string COMMA_DELIMITER = ","; string[] output; IFqFile fqFile = inputs.FastqFile; writer = new StreamWriter(FullName); output = new string[] {"Sequence Index", "Header", "Total Nucleotides", "G Count", "C Count", "Misread Count", "Lower Threshold", "First Quartile", "Median", "Mean", "Third Quartile", "Upper Threshold" }; writer.WriteLine(string.Join(COMMA_DELIMITER, output)); for (int i = 0; i < fqFile.getFastqArraySize(); i++) { FqSequence fqSeq = fqFile.getFastqSequenceByPosition(i); output = new string[] { fqSeq.getSeqIndex().ToString(), fqSeq.getSequenceHeader(), fqSeq.getFastqSeqSize().ToString(), fqSeq.getGCount().ToString(), fqSeq.getCCount().ToString(), fqSeq.getNCount().ToString(), fqSeq.getLowerThreshold().ToString(), fqSeq.getFirstQuartile().ToString(), fqSeq.getMedian().ToString(), fqSeq.getMean().ToString(), fqSeq.getThirdQuartile().ToString(), fqSeq.getUpperThreshold().ToString(), fqSeq.createSequenceString(fqFile.getMap()) }; writer.WriteLine(string.Join(COMMA_DELIMITER, output)); } Console.WriteLine("Saving CSV TO: {0}", FullName); writer.Flush(); writer.Close(); return inputs; }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { inputs.FastqFile.Tests(); return inputs; }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { inputs.FastqFile.removeBelowSequenceLength(inputs.LengthThreshold); inputs.FastqFile.Tests(); return(inputs); }
/// <summary> /// Key method in the display class, makes a decision on what to output based on the previous active task from the generic /// inputs transport class. Also accepts instance of the richtextbox which will display the output. /// </summary> /// <param name="input">Instance of the transport class. Used in this instance to inform the display class of previous activity</param> /// <param name="textBox">The rich text box that will display the outputs</param> public void Update(GenericFastqInputs input, RichTextBox textBox) { this.fqMap = FastqController.getInstance().GetFqFileMap(); this.textBox = textBox; if (input.TaskAction == Task_FindSequences.statement) AddFoundSequenceData(); else { ClearText(); DisplayFileDetails(); DisplayFastqFileDetails(); DisplayComponentDetais(); } }
/// <summary> /// Parses file into component chunks through the parseFastq class before handing component details to FastqController /// for processing. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void loadWorker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; InputFq input = (InputFq)e.Argument; FileStream fileStream = input.fileStream; String fileName = input.fileName; ParseFastq parseFq; if ((worker.CancellationPending == true)) { e.Cancel = true; } else { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); try { worker.ReportProgress(3, "[PARSING FILE]"); parseFq = new ParseFastq(fileStream, fileName); if (parseFq.getFastqFileCheck() == true && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY) { //Create new fqFileMap in controller and prime state for load FastqController.CONTROLLER_STATE = FastqController.FastqControllerState.PARSING; FastqController.getInstance().CreateNewFastqFile(fileName, parseFq.GetFastqFileLength()); FastqController.getInstance().GetFqFileMap().InitializeReadMap(); int fqFileComponentNumber = 1; ProtocolBuffersSerialization protoBuf = new ProtocolBuffersSerialization(); GenericFastqInputs processInputs = new GenericFastqInputs(); processInputs.TaskAction = Task_LoadTask.statement; ITaskStrategy task = TaskDiscrimination.getTask(processInputs.TaskAction); // Uses IEnummerable yield return to parse components back to this class via this foreach loop foreach (FqFile_Component fqFileComponent in parseFq.ParseComponents()) { Double progressPercent = (Double)(((fqFileComponentNumber - 1) * FqFileMap.FQ_BLOCK_LIMIT) / (Double)(parseFq.GetLineCount() / 4)); worker.ReportProgress((int)(progressPercent * 100), ParseFastq.REPORT_STATEMENT); if (fqFileComponent.getFastqArraySize() >= 1) { int threadId; String componentFileName = FastqController.getInstance().GetFqFileMap().FileGUID + "_" + Path.GetFileNameWithoutExtension(fileName) + "_" + fqFileComponentNumber + ProtocolBuffersSerialization.PROTOBUF_FILE_EXTENSION; fqFileComponent.setFastqFileName(componentFileName); fqFileComponent.setComponentNumber(fqFileComponentNumber); fqFileComponent.setFqHashMap(FastqController.getInstance().GetFqFileMap().FqReadMap); processInputs.FastqFile = fqFileComponent; processInputs = task.perform(processInputs); FastqController.getInstance().BuildFqFileMap(processInputs.FastqFile); ProtocolBuffersSerialization.ProbufSerializeFqFile_AsyncMethodCaller caller = new ProtocolBuffersSerialization.ProbufSerializeFqFile_AsyncMethodCaller(protoBuf.ProtobufSerializeFqFile); IAsyncResult result = caller.BeginInvoke((processInputs.FastqFile as FqFile_Component), componentFileName, out threadId, null, null); Boolean returnValue = caller.EndInvoke(out threadId, result); if (returnValue == false) { UserResponse.ErrorResponse("File serialization methods failed, please check you have hard disk space and restart the application", "File Error"); Console.WriteLine("Serialization failed"); loadWorker.CancelAsync(); } else { FastqController.getInstance().addFqFileComponentDirectory(componentFileName); } fqFileComponentNumber++; } } parseFq.CloseReader(); task.confirmTaskEnd(); Console.WriteLine("\n*********\n"); FastqController.getInstance().GetFqFileMap().CalculateGlobalFileScores(); FastqController.getInstance().GetFqFileMap().GlobalDetails.OutputToConsole(); loadWorker.ReportProgress(100, task.getReportStatement()); stopwatch.Stop(); Console.WriteLine("Task: {0} Completed in Time: {1}", task.getStatement(), stopwatch.Elapsed); FastqController.getInstance().GetFqFileMap().LastTask = processInputs.TaskAction; FastqController.getInstance().GetFqFileMap().TimeTaken = stopwatch.Elapsed.ToString(); this.UpdateGUIThread(processInputs); } else { worker.ReportProgress(0, ""); UserResponse.InformationResponse("File does not conform to standard format.", "File Error"); parseFq.CloseReader(); } } catch (IOException exception) { Console.Write(exception.StackTrace); UserResponse.ErrorResponse(exception.ToString()); } catch (InsufficientMemoryException exception) { Console.Write(exception.StackTrace); UserResponse.ErrorResponse(exception.ToString()); } catch (OutOfMemoryException exception) { Console.Write(exception.StackTrace); UserResponse.ErrorResponse(exception.ToString()); } catch (ArithmeticException exception) { Console.Write(exception.StackTrace); UserResponse.ErrorResponse(exception.ToString()); } FastqController.CONTROLLER_STATE = FastqController.FastqControllerState.STATE_READY; stopwatch.Stop(); } }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { //Show error message return inputs; }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { //Show error message return(inputs); }
abstract public GenericFastqInputs perform(GenericFastqInputs inputs);
public override GenericFastqInputs perform(GenericFastqInputs inputs) { inputs.FastqFile.performSequenceStatistics(); return(inputs); }
public GenericFastqInputs cleanAdapters(List<Adapters.Adapter> adapters, Dictionary<int, FqNucleotideRead> map) { String sequence = createSequenceString(map); GenericFastqInputs removedAdapter = null; foreach (Adapters.Adapter adapter in adapters) { Match match = Regex.Match(adapter.AdapterSequence, sequence.ToUpper(), RegexOptions.IgnoreCase); { if (match.Success) { int key = match.Groups[1].Index; cleanEnds(index - key); removedAdapter = new GenericFastqInputs(); removedAdapter.AdapterName = adapter.AdapterName; removedAdapter.SequenceIndex = SequenceIndex; InfoLine = InfoLine + "||Removed Adapter:" + adapter.AdapterName; } } } return removedAdapter; }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { inputs.FastqFile.removeBelowSequenceLength(inputs.LengthThreshold); inputs.FastqFile.Tests(); return inputs; }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { inputs.FastqFile.removeSequencesAboveGCThreshold(inputs.GCThreshold); inputs.FastqFile.Tests(); return inputs; }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { inputs.FastqFile.removeBelowMeanThreshold(inputs.MeanThreshold); inputs.FastqFile.Tests(); return inputs; }
/// <summary> /// The key method in the controller class, where fastqFile_components are serialized and deserialized in and out of /// the classes queues for processing. The tasks are constructed through an interface - ITaskStrategy - which /// is designated through the task abstract factory class (TaskDiscriminator.cs). After processing, files are deserialized and a details class /// for each component is populated, as are the global scores. The use of Abstract/interface classes here allows multiple components /// to be processed with multiple task types within this basic code structure. /// </summary> /// <param name="worker">The backgroundworker thread</param> /// <param name="input">Generic inputs, including taskname and any further details necessary to complete a task such as nucleotide scores etc.</param> public void PerformAction(BackgroundWorker worker, GenericFastqInputs input) { BackgroundWorker loadWorker = worker; if (fqFileMap != null && (CONTROLLER_STATE == FastqControllerState.STATE_READY || CONTROLLER_STATE == FastqControllerState.PARSING)) { sw = new Stopwatch(); sw.Start(); try { toDeserialize = new Queue<String>(fqFileMap.getFileComponentDirectories()); PrimeFqFileComponentQueue(); protobufSerialization = new ProtocolBuffersSerialization(); ITaskStrategy task = TaskDiscrimination.getTask(input.TaskAction); Console.WriteLine("Performing {0}", task.getStatement()); int count = 0; while (toPerform.Count != 0) { Double progressPercent = (Double)(count / (Double)fqFileMap.getFileComponentDirectories().Count); loadWorker.ReportProgress((int)(progressPercent * 100), task.getReportStatement()); FqFile_Component activeComponent = toPerform.Dequeue(); activeComponent.setFqHashMap(fqFileMap.FqReadMap); if (toDeserialize.Count != 0) { int threadId; ProtocolBuffersSerialization.ProbufDeserializeFqFile_AsyncMethodCaller caller = new ProtocolBuffersSerialization.ProbufDeserializeFqFile_AsyncMethodCaller(protobufSerialization.ProtobufDerializeFqFile); String componentFileName = toDeserialize.Dequeue(); IAsyncResult result = caller.BeginInvoke(componentFileName, out threadId, null, null); Console.WriteLine("\n*** Processing: {0} ***\n", activeComponent.getFileName()); input.FastqFile = activeComponent; input = task.perform(input); activeComponent = (FqFile_Component)input.FastqFile; BuildFqFileMap(activeComponent); FqFile_Component returnValue = caller.EndInvoke(out threadId, result); toPerform.Enqueue(returnValue); } else if (toDeserialize.Count == 0) { Console.WriteLine("\n*** Processing: {0} ***\n", activeComponent.getFileName()); input.FastqFile = activeComponent; input = task.perform(input); activeComponent = (FqFile_Component)input.FastqFile; BuildFqFileMap(activeComponent); } toSerialize.Enqueue(activeComponent); SerializeFqComponentToMemory(); count++; } SerializeRemainingFqComponents(); task.confirmTaskEnd(); Console.WriteLine("\n*********\n"); fqFileMap.CalculateGlobalFileScores(); fqFileMap.GlobalDetails.OutputToConsole(); loadWorker.ReportProgress(100, task.getReportStatement()); sw.Stop(); Console.WriteLine("Task: {0} Completed in Time: {1}", task.getStatement(), sw.Elapsed); fqFileMap.LastTask = input.TaskAction; fqFileMap.TimeTaken = sw.Elapsed.ToString(); observer.UpdateGUIThread(input); } catch (IOException exception) { ControllerStateFailureResponse(exception.ToString(), "Error"); } catch (InsufficientMemoryException exception) { ControllerStateFailureResponse(exception.ToString(), "Error"); } catch (OutOfMemoryException exception) { ControllerStateFailureResponse(exception.ToString(), "Error"); } catch (ArithmeticException exception) { ControllerStateFailureResponse(exception.ToString(), "Error"); } sw.Stop(); } }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { inputs.FastqFile.removeBelowMeanThreshold(inputs.MeanThreshold); inputs.FastqFile.Tests(); return(inputs); }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { inputs.FastqFile.removeSequencesWithMisreads(); inputs.FastqFile.Tests(); return inputs; }
/// <summary> /// Parses file into component chunks through the parseFastq class before handing component details to FastqController /// for processing. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void loadWorker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; InputFq input = (InputFq)e.Argument; FileStream fileStream = input.fileStream; String fileName = input.fileName; ParseFastq parseFq; if ((worker.CancellationPending == true)) { e.Cancel = true; } else { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); try { worker.ReportProgress(3, "[PARSING FILE]"); parseFq = new ParseFastq(fileStream, fileName); if (parseFq.getFastqFileCheck() == true && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY) { //Create new fqFileMap in controller and prime state for load FastqController.CONTROLLER_STATE = FastqController.FastqControllerState.PARSING; FastqController.getInstance().CreateNewFastqFile(fileName, parseFq.GetFastqFileLength()); FastqController.getInstance().GetFqFileMap().InitializeReadMap(); int fqFileComponentNumber = 1; ProtocolBuffersSerialization protoBuf = new ProtocolBuffersSerialization(); GenericFastqInputs processInputs = new GenericFastqInputs(); processInputs.TaskAction = Task_LoadTask.statement; ITaskStrategy task = TaskDiscrimination.getTask(processInputs.TaskAction); // Uses IEnummerable yield return to parse components back to this class via this foreach loop foreach (FqFile_Component fqFileComponent in parseFq.ParseComponents()) { Double progressPercent = (Double)(((fqFileComponentNumber-1) * FqFileMap.FQ_BLOCK_LIMIT) / (Double)(parseFq.GetLineCount() / 4)); worker.ReportProgress((int)(progressPercent*100), ParseFastq.REPORT_STATEMENT); if (fqFileComponent.getFastqArraySize() >= 1) { int threadId; String componentFileName = FastqController.getInstance().GetFqFileMap().FileGUID + "_" + Path.GetFileNameWithoutExtension(fileName) + "_" + fqFileComponentNumber + ProtocolBuffersSerialization.PROTOBUF_FILE_EXTENSION; fqFileComponent.setFastqFileName(componentFileName); fqFileComponent.setComponentNumber(fqFileComponentNumber); fqFileComponent.setFqHashMap(FastqController.getInstance().GetFqFileMap().FqReadMap); processInputs.FastqFile = fqFileComponent; processInputs = task.perform(processInputs); FastqController.getInstance().BuildFqFileMap(processInputs.FastqFile); ProtocolBuffersSerialization.ProbufSerializeFqFile_AsyncMethodCaller caller = new ProtocolBuffersSerialization.ProbufSerializeFqFile_AsyncMethodCaller(protoBuf.ProtobufSerializeFqFile); IAsyncResult result = caller.BeginInvoke((processInputs.FastqFile as FqFile_Component), componentFileName, out threadId, null, null); Boolean returnValue = caller.EndInvoke(out threadId, result); if (returnValue == false) { UserResponse.ErrorResponse("File serialization methods failed, please check you have hard disk space and restart the application", "File Error"); Console.WriteLine("Serialization failed"); loadWorker.CancelAsync(); } else { FastqController.getInstance().addFqFileComponentDirectory(componentFileName); } fqFileComponentNumber++; } } parseFq.CloseReader(); task.confirmTaskEnd(); Console.WriteLine("\n*********\n"); FastqController.getInstance().GetFqFileMap().CalculateGlobalFileScores(); FastqController.getInstance().GetFqFileMap().GlobalDetails.OutputToConsole(); loadWorker.ReportProgress(100, task.getReportStatement()); stopwatch.Stop(); Console.WriteLine("Task: {0} Completed in Time: {1}", task.getStatement(), stopwatch.Elapsed); FastqController.getInstance().GetFqFileMap().LastTask = processInputs.TaskAction; FastqController.getInstance().GetFqFileMap().TimeTaken = stopwatch.Elapsed.ToString(); this.UpdateGUIThread(processInputs); } else { worker.ReportProgress(0, ""); UserResponse.InformationResponse("File does not conform to standard format.", "File Error"); parseFq.CloseReader(); } } catch (IOException exception) { Console.Write(exception.StackTrace); UserResponse.ErrorResponse(exception.ToString()); } catch (InsufficientMemoryException exception) { Console.Write(exception.StackTrace); UserResponse.ErrorResponse(exception.ToString()); } catch (OutOfMemoryException exception) { Console.Write(exception.StackTrace); UserResponse.ErrorResponse(exception.ToString()); } catch (ArithmeticException exception) { Console.Write(exception.StackTrace); UserResponse.ErrorResponse(exception.ToString()); } FastqController.CONTROLLER_STATE = FastqController.FastqControllerState.STATE_READY; stopwatch.Stop(); } }
public abstract GenericFastqInputs perform(GenericFastqInputs inputs);
/// <summary> /// The key method in the controller class, where fastqFile_components are serialized and deserialized in and out of /// the classes queues for processing. The tasks are constructed through an interface - ITaskStrategy - which /// is designated through the task abstract factory class (TaskDiscriminator.cs). After processing, files are deserialized and a details class /// for each component is populated, as are the global scores. The use of Abstract/interface classes here allows multiple components /// to be processed with multiple task types within this basic code structure. /// </summary> /// <param name="worker">The backgroundworker thread</param> /// <param name="input">Generic inputs, including taskname and any further details necessary to complete a task such as nucleotide scores etc.</param> public void PerformAction(BackgroundWorker worker, GenericFastqInputs input) { BackgroundWorker loadWorker = worker; if (fqFileMap != null && (CONTROLLER_STATE == FastqControllerState.STATE_READY || CONTROLLER_STATE == FastqControllerState.PARSING)) { sw = new Stopwatch(); sw.Start(); try { toDeserialize = new Queue <String>(fqFileMap.getFileComponentDirectories()); PrimeFqFileComponentQueue(); protobufSerialization = new ProtocolBuffersSerialization(); ITaskStrategy task = TaskDiscrimination.getTask(input.TaskAction); Console.WriteLine("Performing {0}", task.getStatement()); int count = 0; while (toPerform.Count != 0) { Double progressPercent = (Double)(count / (Double)fqFileMap.getFileComponentDirectories().Count); loadWorker.ReportProgress((int)(progressPercent * 100), task.getReportStatement()); FqFile_Component activeComponent = toPerform.Dequeue(); activeComponent.setFqHashMap(fqFileMap.FqReadMap); if (toDeserialize.Count != 0) { int threadId; ProtocolBuffersSerialization.ProbufDeserializeFqFile_AsyncMethodCaller caller = new ProtocolBuffersSerialization.ProbufDeserializeFqFile_AsyncMethodCaller(protobufSerialization.ProtobufDerializeFqFile); String componentFileName = toDeserialize.Dequeue(); IAsyncResult result = caller.BeginInvoke(componentFileName, out threadId, null, null); Console.WriteLine("\n*** Processing: {0} ***\n", activeComponent.getFileName()); input.FastqFile = activeComponent; input = task.perform(input); activeComponent = (FqFile_Component)input.FastqFile; BuildFqFileMap(activeComponent); FqFile_Component returnValue = caller.EndInvoke(out threadId, result); toPerform.Enqueue(returnValue); } else if (toDeserialize.Count == 0) { Console.WriteLine("\n*** Processing: {0} ***\n", activeComponent.getFileName()); input.FastqFile = activeComponent; input = task.perform(input); activeComponent = (FqFile_Component)input.FastqFile; BuildFqFileMap(activeComponent); } toSerialize.Enqueue(activeComponent); SerializeFqComponentToMemory(); count++; } SerializeRemainingFqComponents(); task.confirmTaskEnd(); Console.WriteLine("\n*********\n"); fqFileMap.CalculateGlobalFileScores(); fqFileMap.GlobalDetails.OutputToConsole(); loadWorker.ReportProgress(100, task.getReportStatement()); sw.Stop(); Console.WriteLine("Task: {0} Completed in Time: {1}", task.getStatement(), sw.Elapsed); fqFileMap.LastTask = input.TaskAction; fqFileMap.TimeTaken = sw.Elapsed.ToString(); observer.UpdateGUIThread(input); } catch (IOException exception) { ControllerStateFailureResponse(exception.ToString(), "Error"); } catch (InsufficientMemoryException exception) { ControllerStateFailureResponse(exception.ToString(), "Error"); } catch (OutOfMemoryException exception) { ControllerStateFailureResponse(exception.ToString(), "Error"); } catch (ArithmeticException exception) { ControllerStateFailureResponse(exception.ToString(), "Error"); } sw.Stop(); } }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { inputs.FastqFile.removeSequencesAboveGCThreshold(inputs.GCThreshold); inputs.FastqFile.Tests(); return(inputs); }
/// <summary> /// Method corresponds to the "remove sequences > below mean threshold" button click. It accepts a value for the mean threshold and then /// passes to the controller for processing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void belowMeanThresholdToolStripMenuItem_Click(object sender, EventArgs e) { if (FastqController.getInstance().fqFileMap != null && FastqController.CONTROLLER_STATE == FastqController.FastqControllerState.STATE_READY) { InputBoxResult result = InputBox.Show("Enter the Phred Mean Threshold For Sequences:", "Remove Sequences", "", new InputBoxValidatingHandler(inputBox_MeanThresholdValidating)); if (result.OK) { if (HelperMethods.safeParseInt(result.Text.Trim()) == true) { GenericFastqInputs inputs = new GenericFastqInputs(); inputs.MeanThreshold = Int32.Parse(result.Text.Trim()); inputs.TaskAction = Task_RemoveBelowMeanThreshold.statement; FastqController.getInstance().InitializeAction(inputs); } } } }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { inputs.FastqFile.performSequenceStatistics(); return inputs; }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { inputs.FastqFile.cleanAdapters(); inputs.FastqFile.Tests(); return(inputs); }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { inputs.FastqFile.removeSequencesWithMisreads(); inputs.FastqFile.Tests(); return(inputs); }
public override GenericFastqInputs perform(GenericFastqInputs inputs) { List<FqSequence> foundSequences = inputs.FastqFile.findSequence(inputs.NucleotideSequence); FastqController.getInstance().GetFqFileMap().AddSequenceQueryResults(foundSequences); return inputs; }