/// <summary>
        ///     Matches DNA with the primer.
        /// </summary>
        /// <param name="sequence">The DNA to search for.</param>
        /// <returns>A primer if found, or null if none is found.</returns>
        public PrimerMatch Match(FastQSequence sequence)
        {
            var dna = sequence.Sequence;

            for (int i = 0; i < (dna.Length - Primer.Length); i++)
            {
                int errorCount = 0;
                for (int j = 0; j < Primer.Length; j++)
                {
                    if (dna[i + j] != Primer[j])
                    {
                        errorCount++;
                    }
                    if (errorCount > ErrorBound)
                    {
                        break;
                    }
                }
                if (errorCount <= ErrorBound)
                {
                    return(new PrimerMatch(i, errorCount));
                }
            }

            return(null);
        }
        /// <summary>
        ///     Matches DNA with the primer.
        /// </summary>
        /// <param name="sequence">The DNA to search for.</param>
        /// <returns>A primer if found, or null if none is found.</returns>
        public bool TryMatch(FastQSequence sequence, out PrimerMatch result)
        {
            var dna = sequence.Sequence;

            for (var i = 0; i < dna.Length - Primer.Length; i++)
            {
                var errorCount = 0;
                for (var j = 0; j < Primer.Length; j++)
                {
                    if (dna[i + j] != Primer[j])
                    {
                        errorCount++;
                    }

                    if (errorCount > ErrorBound)
                    {
                        break;
                    }
                }

                if (errorCount <= ErrorBound)
                {
                    result = new PrimerMatch(i, errorCount);
                    return(true);
                }
            }

            result = default;
            return(false);
        }
Beispiel #3
0
 public PrimerResult(FastQSequence forward, FastQSequence reverse, PrimerScanner.PrimerMatch forwardMatch,
                     PrimerScanner.PrimerMatch reverseMatch, bool reversed)
 {
     Forward      = forward;
     Reverse      = reverse;
     ForwardMatch = forwardMatch;
     ReverseMatch = reverseMatch;
     Reversed     = reversed;
 }
Beispiel #4
0
 public static bool TryFind <T>(FastQSequence h1, FastQSequence h2, T scanners, out PrimerResult result)
     where T : IEnumerable <(PrimerScanner forward, PrimerScanner reverse)>
 FindPrimer(FastQSequence h1, FastQSequence h2, List <(PrimerScanner forward, PrimerScanner reverse)> scanners)