protected override async void OnStartup(StartupEventArgs e) { var appIcon = WpfUI.Properties.Resources.M; var assemblyParameters = AssemblyParameters.CreateFromAssembly(typeof(App).Assembly); var appConfig = ApplicationConfiguration.CreateFromIcon("Word Analysis System", appIcon); await BootstrapService.StartUpAsync(assemblyParameters, appConfig); }
/// <summary> /// Validates the Sequences for all the general test cases. /// </summary> /// <param name="node">Xml Node Name</param> /// <param name="additionalParameter"> /// Additional Parameter based /// on which the validations are done. /// </param> private void ValidateComputeFeature(string node, AssemblyParameters additionalParameter) { // Get the parameters from Xml string firstSequence = utilityObj.xmlUtil.GetTextValue(node, Constants.SequenceNode1); string secondSequence = utilityObj.xmlUtil.GetTextValue(node, Constants.SequenceNode2); string kmerLength = utilityObj.xmlUtil.GetTextValue(node, Constants.KmerLengthNode); string expectedFeatureCount = utilityObj.xmlUtil.GetTextValue(node, Constants.FeatureCount); string expectedFeature = utilityObj.xmlUtil.GetTextValue(node, Constants.FeatureName); string expectedFeatureType = utilityObj.xmlUtil.GetTextValue(node, Constants.FeatureType); string expectedStartIndex = utilityObj.xmlUtil.GetTextValue(node, Constants.StartIndexNode); string expectedEndIndex = utilityObj.xmlUtil.GetTextValue(node, Constants.EndIndexNode); ISequence seq1 = null; ISequence seq2 = null; // Create Sequences. switch (additionalParameter) { case AssemblyParameters.Assemble: var seqObj1 = new Sequence(Alphabets.Protein, firstSequence); var seqObj2 = new Sequence(Alphabets.Protein, secondSequence); seq1 = seqObj1; seq2 = seqObj2; break; case AssemblyParameters.Consensus: seq1 = new Sequence(Alphabets.DNA, firstSequence); seq2 = new Sequence(Alphabets.DNA, secondSequence); break; } var kmerBuilder = new SequenceToKmerBuilder(); KmersOfSequence kmerList = kmerBuilder.Build(seq1, int.Parse(kmerLength, null)); List <WordMatch> nodes = WordMatch.BuildMatchTable( kmerList, seq2, int.Parse(kmerLength, null)); List <WordMatch> matchList = WordMatch.GetMinimalList(nodes, int.Parse(kmerLength, null)); List <DifferenceNode> diffNode = DifferenceNode.BuildDiffList(matchList, seq1, seq2); List <DifferenceNode.CompareFeature> features = DifferenceNode.OutputDiffList(diffNode, seq1, seq2); // Validate difference. Assert.AreEqual(expectedFeatureCount, features.Count.ToString((IFormatProvider)null)); Assert.AreEqual(expectedFeature, features[0].Feature); Assert.AreEqual(expectedFeatureType, features[0].FeatureType); Assert.AreEqual(expectedStartIndex, features[0].Start.ToString((IFormatProvider)null)); Assert.AreEqual(expectedEndIndex, features[0].End.ToString((IFormatProvider)null)); ApplicationLog.WriteLine(string.Format(null, "Kmer P1 : Validated DifferenceNodes successfully.")); }
private static IServiceProvider CreateServiceProvider(IServiceCollection services) { var container = ContainerInitializationService.CreateInitializedContainer( AssemblyParameters.CreateFromAssembly(typeof(ServiceInitialization).Assembly)); container.Populate(services); var result = container.GetInstance <IServiceProvider>(); return(result); }
/// <summary> /// Validates the Sequence Assembler for all the general test cases. /// </summary> /// <param name="nodeName">Xml Node Name</param> /// <param name="additionalParameter"> /// Additional Parameter based /// on which the validations are done. /// </param> /// <param name="isSeqAssemblyctr">True if Default contructor is validated or else false.</param> private void ValidateSequenceAssemblerGeneral(string nodeName, AssemblyParameters additionalParameter, bool isSeqAssemblyctr) { // Get the parameters from Xml int matchScore = int.Parse(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MatchScoreNode), null); int mismatchScore = int.Parse(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MisMatchScoreNode), null); int gapCost = int.Parse(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.GapCostNode), null); double mergeThreshold = double.Parse(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MergeThresholdNode), null); double consensusThreshold = double.Parse(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ConsensusThresholdNode), null); string[] sequences = utilityObj.xmlUtil.GetTextValues(nodeName, Constants.SequencesNode); IAlphabet alphabet = Utility.GetAlphabet(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.AlphabetNameNode)); string documentation = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.DocumentaionNode); var info = new SerializationInfo(typeof(OverlapDeNovoAssembly), new FormatterConverter()); var context = new StreamingContext(StreamingContextStates.All); var inputs = new List <ISequence>(); switch (additionalParameter) { case AssemblyParameters.Consensus: for (int i = 0; i < sequences.Length; i++) { // Logs the sequences ApplicationLog.WriteLine(string.Format(null, "SimpleConsensusMethod P1 : Sequence '{0}' used is '{1}'.", i, sequences[i])); var seq = new Sequence(alphabet, sequences[i]); inputs.Add(seq); } break; default: for (int i = 0; i < sequences.Length; i++) { // Logs the sequences ApplicationLog.WriteLine(string.Format(null, "SequenceAssembly P1 : Sequence '{0}' used is '{1}'.", i, sequences[i])); var seq = new Sequence(alphabet, sequences[i]); inputs.Add(seq); } break; } // here is how the above sequences should align: // TATAAAGCGCCAA // GCCAAAATTTAGGC // AGGCACCCGCGGTATT <= reversed // // TATAAAGCGCCAAAATTTAGGCACCCGCGGTATT var assembler = new OverlapDeNovoAssembler { MergeThreshold = mergeThreshold, OverlapAlgorithm = new PairwiseOverlapAligner() }; switch (additionalParameter) { case AssemblyParameters.DiagonalSM: (assembler.OverlapAlgorithm).SimilarityMatrix = new DiagonalSimilarityMatrix(matchScore, mismatchScore); break; case AssemblyParameters.SimilarityMatrix: string blosumFilePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.BlosumFilePathNode); (assembler.OverlapAlgorithm).SimilarityMatrix = new SimilarityMatrix(blosumFilePath); break; default: (assembler.OverlapAlgorithm).SimilarityMatrix = new DiagonalSimilarityMatrix(matchScore, mismatchScore); break; } (assembler.OverlapAlgorithm).GapOpenCost = gapCost; assembler.ConsensusResolver = new SimpleConsensusResolver(consensusThreshold); assembler.AssumeStandardOrientation = false; // Assembles all the sequences. IOverlapDeNovoAssembly assembly = (IOverlapDeNovoAssembly)assembler.Assemble(inputs); // Set Documentation property. assembly.Documentation = documentation; // Get the parameters from Xml in general int contigSequencesCount = int.Parse(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ContigSequencesCountNode), null); string contigConsensus = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ContigConsensusNode); switch (additionalParameter) { case AssemblyParameters.Consensus: // Read the contig from Contig method. Contig contigReadForConsensus = assembly.Contigs[0]; contigReadForConsensus.Consensus = null; var simpleSeqAssembler = new OverlapDeNovoAssembler { ConsensusResolver = new SimpleConsensusResolver(consensusThreshold) }; simpleSeqAssembler.MakeConsensus(alphabet, contigReadForConsensus); // Log the required info. ApplicationLog.WriteLine(string.Format(null, "SimpleConsensusMethod BVT : Consensus read is '{0}'.", contigReadForConsensus.Consensus)); Assert.AreEqual(contigConsensus, new String(contigReadForConsensus.Consensus.Select(a => (char)a).ToArray())); break; default: // Get the parameters from Xml for Assemble() method test cases. int unMergedCount = int.Parse(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.UnMergedSequencesCountNode), null); int contigsCount = int.Parse(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ContigsCountNode), null); Assert.AreEqual(unMergedCount, assembly.UnmergedSequences.Count); Assert.AreEqual(contigsCount, assembly.Contigs.Count); Assert.AreEqual(documentation, assembly.Documentation); Contig contigRead = assembly.Contigs[0]; // Logs the consensus ApplicationLog.WriteLine(string.Format(null, "SequenceAssembly BVT : Un Merged Sequences Count is '{0}'.", assembly.UnmergedSequences.Count)); ApplicationLog.WriteLine(string.Format(null, "SequenceAssembly BVT : Contigs Count is '{0}'.", assembly.Contigs.Count)); ApplicationLog.WriteLine(string.Format(null, "SequenceAssembly BVT : Contig Sequences Count is '{0}'.", contigRead.Sequences.Count)); ApplicationLog.WriteLine(string.Format(null, "SequenceAssembly BVT : Consensus read is '{0}'.", contigRead.Consensus)); Assert.AreEqual(contigConsensus, new String(contigRead.Consensus.Select(a => (char)a).ToArray())); Assert.AreEqual(contigSequencesCount, contigRead.Sequences.Count); break; } }
/// <summary> /// Validates the Sequences for all the general test cases. /// </summary> /// <param name="node">Xml Node Name</param> /// <param name="additionalParameter"> /// Additional Parameter based /// on which the validations are done. /// </param> private void ValidateComputeFeature(string node, AssemblyParameters additionalParameter) { // Get the parameters from Xml string firstSequence = this.utilityObj.xmlUtil.GetTextValue(node, Constants.SequenceNode1); string secondSequence = this.utilityObj.xmlUtil.GetTextValue(node, Constants.SequenceNode2); string kmerLength = this.utilityObj.xmlUtil.GetTextValue(node, Constants.KmerLengthNode); string expectedFeatureCount = this.utilityObj.xmlUtil.GetTextValue(node, Constants.FeatureCount); string expectedFeature = this.utilityObj.xmlUtil.GetTextValue(node, Constants.FeatureName); string expectedFeatureType = this.utilityObj.xmlUtil.GetTextValue(node, Constants.FeatureType); string expectedStartIndex = this.utilityObj.xmlUtil.GetTextValue(node, Constants.StartIndexNode); string expectedEndIndex = this.utilityObj.xmlUtil.GetTextValue(node, Constants.EndIndexNode); ISequence seq1 = null; ISequence seq2 = null; // Create Sequences. switch (additionalParameter) { case AssemblyParameters.Assemble: var seqObj1 = new Sequence(Alphabets.Protein, firstSequence); var seqObj2 = new Sequence(Alphabets.Protein, secondSequence); seq1 = seqObj1; seq2 = seqObj2; break; case AssemblyParameters.Consensus: seq1 = new Sequence(Alphabets.DNA, firstSequence); seq2 = new Sequence(Alphabets.DNA, secondSequence); break; } var kmerBuilder = new SequenceToKmerBuilder(); KmersOfSequence kmerList = kmerBuilder.Build(seq1, int.Parse(kmerLength, null)); List<WordMatch> nodes = WordMatch.BuildMatchTable( kmerList, seq2, int.Parse(kmerLength, null)); List<WordMatch> matchList = WordMatch.GetMinimalList(nodes, int.Parse(kmerLength, null)); List<DifferenceNode> diffNode = DifferenceNode.BuildDiffList(matchList, seq1, seq2); List<DifferenceNode.CompareFeature> features = DifferenceNode.OutputDiffList(diffNode, seq1, seq2); // Validate difference. Assert.AreEqual(expectedFeatureCount, features.Count.ToString((IFormatProvider) null)); Assert.AreEqual(expectedFeature, features[0].Feature); Assert.AreEqual(expectedFeatureType, features[0].FeatureType); Assert.AreEqual(expectedStartIndex, features[0].Start.ToString((IFormatProvider) null)); Assert.AreEqual(expectedEndIndex, features[0].End.ToString((IFormatProvider) null)); ApplicationLog.WriteLine(string.Format(null, "Kmer P1 : Validated DifferenceNodes successfully.")); }
/// <summary> /// Validates the Sequence Assembler for all the general test cases. /// </summary> /// <param name="nodeName">Xml Node Name</param> /// <param name="additionalParameter"> /// Additional Parameter based /// on which the validations are done. /// </param> /// <param name="isSeqAssemblyctr">True if Default contructor is validated or else false.</param> private void ValidateSequenceAssemblerGeneral(string nodeName, AssemblyParameters additionalParameter, bool isSeqAssemblyctr) { // Get the parameters from Xml int matchScore = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MatchScoreNode), null); int mismatchScore = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MisMatchScoreNode), null); int gapCost = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.GapCostNode), null); double mergeThreshold = double.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MergeThresholdNode), null); double consensusThreshold = double.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ConsensusThresholdNode), null); string[] sequences = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.SequencesNode); IAlphabet alphabet = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.AlphabetNameNode)); string documentation = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.DocumentaionNode); var info = new SerializationInfo(typeof (OverlapDeNovoAssembly), new FormatterConverter()); var context = new StreamingContext(StreamingContextStates.All); var inputs = new List<ISequence>(); switch (additionalParameter) { case AssemblyParameters.Consensus: for (int i = 0; i < sequences.Length; i++) { // Logs the sequences ApplicationLog.WriteLine(string.Format(null, "SimpleConsensusMethod P1 : Sequence '{0}' used is '{1}'.", i, sequences[i])); var seq = new Sequence(alphabet, sequences[i]); inputs.Add(seq); } break; default: for (int i = 0; i < sequences.Length; i++) { // Logs the sequences ApplicationLog.WriteLine(string.Format(null, "SequenceAssembly P1 : Sequence '{0}' used is '{1}'.", i, sequences[i])); var seq = new Sequence(alphabet, sequences[i]); inputs.Add(seq); } break; } // here is how the above sequences should align: // TATAAAGCGCCAA // GCCAAAATTTAGGC // AGGCACCCGCGGTATT <= reversed // // TATAAAGCGCCAAAATTTAGGCACCCGCGGTATT var assembler = new OverlapDeNovoAssembler { MergeThreshold = mergeThreshold, OverlapAlgorithm = new PairwiseOverlapAligner() }; switch (additionalParameter) { case AssemblyParameters.DiagonalSM: (assembler.OverlapAlgorithm).SimilarityMatrix = new DiagonalSimilarityMatrix(matchScore, mismatchScore); break; case AssemblyParameters.SimilarityMatrix: string blosumFilePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.BlosumFilePathNode); (assembler.OverlapAlgorithm).SimilarityMatrix = new SimilarityMatrix(new StreamReader(blosumFilePath)); break; default: (assembler.OverlapAlgorithm).SimilarityMatrix = new DiagonalSimilarityMatrix(matchScore, mismatchScore); break; } (assembler.OverlapAlgorithm).GapOpenCost = gapCost; assembler.ConsensusResolver = new SimpleConsensusResolver(consensusThreshold); assembler.AssumeStandardOrientation = false; // Assembles all the sequences. IOverlapDeNovoAssembly assembly = (IOverlapDeNovoAssembly) assembler.Assemble(inputs); // Set Documentation property. assembly.Documentation = documentation; // Get the parameters from Xml in general int contigSequencesCount = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ContigSequencesCountNode), null); string contigConsensus = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ContigConsensusNode); switch (additionalParameter) { case AssemblyParameters.Consensus: // Read the contig from Contig method. Contig contigReadForConsensus = assembly.Contigs[0]; contigReadForConsensus.Consensus = null; var simpleSeqAssembler = new OverlapDeNovoAssembler { ConsensusResolver = new SimpleConsensusResolver(consensusThreshold) }; simpleSeqAssembler.MakeConsensus(alphabet, contigReadForConsensus); // Log the required info. ApplicationLog.WriteLine(string.Format(null, "SimpleConsensusMethod BVT : Consensus read is '{0}'.", contigReadForConsensus.Consensus)); Assert.AreEqual(contigConsensus, new String(contigReadForConsensus.Consensus.Select(a => (char) a).ToArray())); break; default: // Get the parameters from Xml for Assemble() method test cases. int unMergedCount = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.UnMergedSequencesCountNode), null); int contigsCount = int.Parse(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ContigsCountNode), null); Assert.AreEqual(unMergedCount, assembly.UnmergedSequences.Count); Assert.AreEqual(contigsCount, assembly.Contigs.Count); Assert.AreEqual(documentation, assembly.Documentation); Contig contigRead = assembly.Contigs[0]; // Logs the consensus ApplicationLog.WriteLine(string.Format(null, "SequenceAssembly BVT : Un Merged Sequences Count is '{0}'.", assembly.UnmergedSequences.Count)); ApplicationLog.WriteLine(string.Format(null, "SequenceAssembly BVT : Contigs Count is '{0}'.", assembly.Contigs.Count)); ApplicationLog.WriteLine(string.Format(null, "SequenceAssembly BVT : Contig Sequences Count is '{0}'.", contigRead.Sequences.Count)); ApplicationLog.WriteLine(string.Format(null, "SequenceAssembly BVT : Consensus read is '{0}'.", contigRead.Consensus)); Assert.AreEqual(contigConsensus, new String(contigRead.Consensus.Select(a => (char) a).ToArray())); Assert.AreEqual(contigSequencesCount, contigRead.Sequences.Count); break; } }