private IEnumerable <AnnotationAndOffset> AnnotationsAndOffsetsParallelInternal(int minLength, int numTolerableTermini, int numMissedCleavages, IEnumerable <char> enzymaticResidues, bool isNTermEnzyme, SequenceLcpAndOffset seqAndLcp, bool[] isCleavable, bool[] isStandardAminoAcid ) { var seqArr = Encoding.GetString(seqAndLcp.Sequence); //var seqArr = seqAndLcp.Sequence; var lcp = seqAndLcp.Lcp; var offset = seqAndLcp.Offset; var seqBuild = new StringBuilder(seqArr.Length + 3); seqBuild.Append(seqArr[0] + "."); if (enzymaticResidues != null) { var ntt = 0; var nmc = 0; if (!isNTermEnzyme) // C-term enzyme { if (isCleavable[seqArr[0]]) { ++ntt; } if (!(ntt < numTolerableTermini - 1)) { // Could be run in parallel, but probably not worth the cost. for (var i = 1; i < seqArr.Length - 1; i++) { var code = seqArr[i]; if (!isStandardAminoAcid[code]) { break; } if (isCleavable[code]) { ++nmc; } seqBuild.Append(code); if (i >= minLength && i >= lcp) { if (ntt + (isCleavable[code] || seqArr[i + 1] == FastaDatabaseConstants.Delimiter ? 1 : 0) >= numTolerableTermini) { yield return(new AnnotationAndOffset(offset, seqBuild + "." + seqArr[i + 1])); } } if (nmc > numMissedCleavages) { break; } } } } else // N-term enzyme { if (seqArr[0] == FastaDatabaseConstants.Delimiter || isCleavable[seqArr[1]]) { ++ntt; } if (!(ntt < numTolerableTermini - 1)) { // Could be run in parallel, but probably not worth the cost. for (var i = 2; i < seqArr.Length - 1; i++) { var code = seqArr[i]; if (!isStandardAminoAcid[code]) { break; } if (isCleavable[code]) { ++nmc; } if (nmc > numMissedCleavages) { break; } seqBuild.Append(code); if (i >= minLength && i >= lcp) { if (ntt + (isCleavable[seqArr[i + 1]] ? 1 : 0) >= numTolerableTermini) { yield return(new AnnotationAndOffset(offset, seqBuild + "." + seqArr[i + 1])); } } } } } } else // No enzyme { // Could be run in parallel, but probably not worth the cost. for (var i = 1; i < seqArr.Length - 1; i++) { var code = seqArr[i]; if (!isStandardAminoAcid[code]) { break; } seqBuild.Append(code); if (i >= minLength && i >= lcp) { yield return(new AnnotationAndOffset(offset, seqBuild + "." + seqArr[i + 1])); } } } }
private IEnumerable<AnnotationAndOffset> AnnotationsAndOffsetsParallelInternal(int minLength, int numTolerableTermini, int numMissedCleavages, IEnumerable<char> enzymaticResidues, bool isNTermEnzyme, SequenceLcpAndOffset seqAndLcp, bool[] isCleavable, bool[] isStandardAminoAcid ) { var seqArr = Encoding.GetString(seqAndLcp.Sequence); //var seqArr = seqAndLcp.Sequence; var lcp = seqAndLcp.Lcp; var offset = seqAndLcp.Offset; var seqBuild = new StringBuilder(seqArr.Length + 3); seqBuild.Append(seqArr[0] + "."); if (enzymaticResidues != null) { var ntt = 0; var nmc = 0; if (!isNTermEnzyme) // C-term enzyme { if (isCleavable[seqArr[0]]) ++ntt; if (!(ntt < numTolerableTermini-1)) { // Could be run in parallel, but probably not worth the cost. for (var i = 1; i < seqArr.Length-1; i++) { var code = seqArr[i]; if (!isStandardAminoAcid[code]) break; if (isCleavable[code]) ++nmc; seqBuild.Append(code); if (i >= minLength && i >= lcp) { if (ntt + (isCleavable[code] || seqArr[i+1] == FastaDatabase.Delimiter ? 1 : 0) >= numTolerableTermini) { yield return new AnnotationAndOffset(offset, seqBuild + "." + seqArr[i + 1]); } } if (nmc > numMissedCleavages) break; } } } else // N-term enzyme { if (seqArr[0] == FastaDatabase.Delimiter || isCleavable[seqArr[1]]) ++ntt; if (!(ntt < numTolerableTermini - 1)) { // Could be run in parallel, but probably not worth the cost. for (var i = 2; i < seqArr.Length - 1; i++) { var code = seqArr[i]; if (!isStandardAminoAcid[code]) break; if (isCleavable[code]) ++nmc; if (nmc > numMissedCleavages) break; seqBuild.Append(code); if (i >= minLength && i >= lcp) { if (ntt + (isCleavable[seqArr[i + 1]] ? 1 : 0) >= numTolerableTermini) { yield return new AnnotationAndOffset(offset, seqBuild + "." + seqArr[i + 1]); } } } } } } else // No enzyme { // Could be run in parallel, but probably not worth the cost. for (var i = 1; i < seqArr.Length-1; i++) { var code = seqArr[i]; if (!isStandardAminoAcid[code]) break; seqBuild.Append(code); if (i >= minLength && i >= lcp) { yield return new AnnotationAndOffset(offset, seqBuild + "." + seqArr[i + 1]); } } } }