示例#1
0
        /// <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."));
        }
示例#2
0
        public static void FindDifferencesInSequences(string firstFile, string secondFile)
        {
            // parsowanie pierwszej listy
            if (!SequenceParsers.IsFasta(firstFile))
            {
                Console.WriteLine("Nieprawidlowy format pierwszego pliku!");
                return;
            }

            if (!SequenceParsers.IsFasta(secondFile))
            {
                Console.WriteLine("Nieprawidlowy format drugiego pliku!");
                return;
            }

            var firstParser = SequenceParsers.FindParserByFileName(firstFile);

            firstParser.Alphabet = AmbiguousProteinAlphabet.Instance;
            var firstSequenceList  = firstParser.Parse();
            var firstFileSequences = Helper.ConvertIenumerableToList(firstSequenceList);

            // parsowanie drugiej listy
            var secondParser = SequenceParsers.FindParserByFileName(firstFile);

            secondParser.Alphabet = AmbiguousProteinAlphabet.Instance;
            var secondSequenceList  = secondParser.Parse();
            var secondFileSequences = Helper.ConvertIenumerableToList(secondSequenceList);

            // pobranie listy KMER'ów
            var kmerBuilder = new SequenceToKmerBuilder();
            var kmerList    = kmerBuilder.Build(firstFileSequences.First(), 2);
            var nodes       = WordMatch.BuildMatchTable(kmerList, secondFileSequences.First(), 2);

            var list2 = new List <WordMatch>(nodes);

            var matchList = WordMatch.GetMinimalList(list2, 2);

            var list3 = new List <WordMatch>(matchList);

            // znajdŸ ró¿nice miêdzy wêz³ami
            var diffNode = DifferenceNode.BuildDiffList(list3, firstFileSequences.First(), secondFileSequences.First());

            var list4 = new List <DifferenceNode>(diffNode);

            var features = DifferenceNode.OutputDiffList(list4, firstFileSequences.First(), secondFileSequences.First());

            foreach (var compareFeature in features)
            {
                Console.WriteLine(compareFeature.Feature);
            }
        }
示例#3
0
        public void SequenceCompare()
        {
            ISequence seq1 = new Sequence(Alphabets.DNA, "AAAAAA");
            ISequence seq2 = new Sequence(Alphabets.DNA, "AAATAA");

            SequenceToKmerBuilder kmerBuilder             = new SequenceToKmerBuilder();
            KmersOfSequence       kmers                   = kmerBuilder.Build(seq1, 2);
            List <WordMatch>      nodes                   = WordMatch.BuildMatchTable(kmers, seq1, seq2, 2);
            List <WordMatch>      matchList               = WordMatch.GetMinimalList(nodes, 2);
            List <DifferenceNode> diffNode                = DifferenceNode.BuildDiffList(matchList, seq1, seq2);
            List <DifferenceNode.CompareFeature> features = DifferenceNode.OutputDiffList(diffNode, seq1, seq2);

            Assert.AreEqual(features.Count, 4);
            Assert.AreEqual(features[0].Feature, "Insertion of 1 bases in 2 ");
            Assert.AreEqual(features[1].FeatureType, "REPLACE");
            Assert.AreEqual(features[2].Feature, "Insertion of 1 bases in 1 ");
            Assert.AreEqual(features[3].FeatureType, "REPLACE");
        }
示例#4
0
        public void ValidateSequenceCompare()
        {
            string firstSequence = utilityObj.xmlUtil.GetTextValue(Constants.SequenceCompareNode,
                                                                   Constants.SequenceNode1);
            string secondSequence = utilityObj.xmlUtil.GetTextValue(Constants.SequenceCompareNode,
                                                                    Constants.SequenceNode2);
            string replace = utilityObj.xmlUtil.GetTextValue(Constants.SequenceCompareNode,
                                                             Constants.ReplaceNode);
            ISequence             seq1                    = new Sequence(Alphabets.DNA, firstSequence);
            ISequence             seq2                    = new Sequence(Alphabets.DNA, secondSequence);
            var                   kmerBuilder             = new SequenceToKmerBuilder();
            KmersOfSequence       kmers                   = kmerBuilder.Build(seq1, 2);
            List <WordMatch>      nodes                   = WordMatch.BuildMatchTable(kmers, seq2, 2);
            List <WordMatch>      matchList               = WordMatch.GetMinimalList(nodes, 2);
            List <DifferenceNode> diffNode                = DifferenceNode.BuildDiffList(matchList, seq1, seq2);
            List <DifferenceNode.CompareFeature> features = DifferenceNode.OutputDiffList(diffNode, seq1, seq2);

            //Validating the bahavior.
            Assert.AreEqual(features.Count, 4);
            Assert.AreEqual(features[0].Feature, Constants.InsertionOfOneBaseIn2);
            Assert.AreEqual(features[1].FeatureType, replace);
            Assert.AreEqual(features[2].Feature, Constants.InsertionOfOneBaseIn1);
            Assert.AreEqual(features[3].FeatureType, replace);
        }