Ejemplo n.º 1
0
        public void GetCodon_NullPrefixAndSuffix()
        {
            const string allele         = "GAA";
            var          observedResult = Codons.GetCodon(allele, "", "");

            Assert.Equal(allele, observedResult);
        }
Ejemplo n.º 2
0
        private static void AssignExtended(string transcriptReferenceAllele, string transcriptAlternateAllele,
                                           NullableInterval cdsInterval, NullableInterval proteinInterval, ISequence codingSequence, out string refCodons, out string altCodons)
        {
            refCodons = null;
            altCodons = null;

            if (cdsInterval.Start == null || cdsInterval.End == null || proteinInterval.Start == null ||
                proteinInterval.End == null)
            {
                return;
            }

            int aminoAcidStart = proteinInterval.Start.Value * 3 - 2;
            int aminoAcidEnd   = proteinInterval.End.Value * 3;

            int prefixLen = cdsInterval.Start.Value - aminoAcidStart;
            int suffixLen = aminoAcidEnd - cdsInterval.End.Value;

            int start1 = aminoAcidStart - 1;
            int start2 = aminoAcidEnd - suffixLen;

            int maxSuffixLen = codingSequence.Length - start2;

            var atTailEnd = false;

            if (suffixLen > maxSuffixLen)
            {
                suffixLen = maxSuffixLen;
                atTailEnd = true;
            }

            if (suffixLen > maxSuffixLen)
            {
                suffixLen = maxSuffixLen;
            }

            string prefix = start1 + prefixLen < codingSequence.Length
                ? codingSequence.Substring(start1, prefixLen).ToLower()
                : "AAA";

            string suffix = suffixLen > 0
                ? codingSequence.Substring(start2, suffixLen).ToLower()
                : "";

            var needExtend  = !atTailEnd && !Codons.IsTriplet(prefixLen + suffixLen + transcriptAlternateAllele.Length);
            var extendedLen = (maxSuffixLen - suffixLen) > 45 ? 45 : (maxSuffixLen - suffixLen) / 3 * 3;

            if (needExtend)
            {
                suffix = codingSequence.Substring(start2, suffixLen + extendedLen);
            }


            refCodons = Codons.GetCodon(transcriptReferenceAllele, prefix, suffix);
            altCodons = Codons.GetCodon(transcriptAlternateAllele, prefix, suffix);
        }