コード例 #1
0
        public void ToString_ProducesExpectedOutput()
        {
            string expectedSequence      = "ABC-";
            var    aminoAcidSequenceData = AminoAcidSequence.Parse(expectedSequence);

            Assert.AreEqual(expectedSequence, aminoAcidSequenceData.ToString());
        }
コード例 #2
0
        public void Parse_ShouldAcceptTranslationStop()
        {
            string expectedSequence      = "ABC*";
            var    aminoAcidSequenceData = AminoAcidSequence.Parse(expectedSequence);

            Assert.AreEqual(expectedSequence, aminoAcidSequenceData.Characters);
        }
コード例 #3
0
        public void ToInterleavedLines_ShouldProduceExpectedOutputForNonDefaultLineLength()
        {
            string inputSequence = "MDSKGSSQKGSRLLLLLVVSNLLLCQGVVSTPVCPNGPGNCQVSLRDLFDRAVMVSHYIHDLSS"
                                   + "EMFNEFDKRYAQGKGFITMALNSCHTSSLPTPEDKEQAQQTHHEVLMSLILGLLRSWNDPLYHL";

            IEnumerable <string> expectedOutputLines = new string[] {
                ">lcl|123",
                "MDSKGSSQ",
                "KGSRLLLL",
                "LVVSNLLL",
                "CQGVVSTP",
                "VCPNGPGN",
                "CQVSLRDL",
                "FDRAVMVS",
                "HYIHDLSS",
                "EMFNEFDK",
                "RYAQGKGF",
                "ITMALNSC",
                "HTSSLPTP",
                "EDKEQAQQ",
                "THHEVLMS",
                "LILGLLRS",
                "WNDPLYHL"
            };

            Identifier      identifier          = new LocalIdentifier("123");
            Header          header              = new Header(identifier);
            IActualSequence sequence            = AminoAcidSequence.Parse(inputSequence);
            var             singleFASTAFileData = new Sequence(header, sequence);

            IEnumerable <string> actualOutputLines = singleFASTAFileData.ToInterleavedLines(8);

            CollectionAssert.AreEqual(expectedOutputLines.ToList(), actualOutputLines.ToList());
        }
コード例 #4
0
        public void Parse_ShouldAcceptGaps()
        {
            string expectedSequence      = "ABC-";
            var    aminoAcidSequenceData = AminoAcidSequence.Parse(expectedSequence);

            Assert.AreEqual(expectedSequence, aminoAcidSequenceData.Characters);
        }
コード例 #5
0
        public void ToLines_RejectsLineLengthOfZero()
        {
            string sequence = "ABCDEF";

            var aminoAcidSequenceData = AminoAcidSequence.Parse(sequence);

            _ = aminoAcidSequenceData.ToLines(0);
        }
コード例 #6
0
        public void ToLines_RejectsNegativeLineLength()
        {
            string sequence = "ABCDEF";

            var aminoAcidSequenceData = AminoAcidSequence.Parse(sequence);

            _ = aminoAcidSequenceData.ToLines(-1);
        }
コード例 #7
0
ファイル: PdbReader.cs プロジェクト: frke/genome-tools
        private static void ValidateSequences(AminoAcidSequence seqresSequence, AminoAcidSequence atomSequence)
        {
            var seqresQueue       = new Queue <AminoAcidSequenceItem>(seqresSequence);
            var atomSequenceQueue = new Queue <AminoAcidSequenceItem>(atomSequence);

            while (seqresQueue.Any() && atomSequenceQueue.Any())
            {
            }
        }
コード例 #8
0
        public void ToMultilineString_ProducesExpectedOutput()
        {
            string sequence      = "ABCDEF";
            string expectedLines = $"ABCD{Environment.NewLine}EF";

            var    aminoAcidSequenceData = AminoAcidSequence.Parse(sequence);
            string actualLines           = aminoAcidSequenceData.ToMultilineString(4);

            Assert.AreEqual(expectedLines, actualLines);
        }
コード例 #9
0
        public void ToLines_ProducesExpectedOutput()
        {
            string sequence      = "ABCDEF";
            var    expectedLines = new string[] { "ABCD", "EF" };

            var aminoAcidSequenceData        = AminoAcidSequence.Parse(sequence);
            IEnumerable <string> actualLines = aminoAcidSequenceData.ToLines(4);

            Assert.IsTrue(actualLines.SequenceEqual(expectedLines));
        }
コード例 #10
0
        public void ToInterleavedLines_ShouldRejectLineLengthOfZero()
        {
            string inputSequence = "MDSKGSSQKGSRLLLLLVVSNLLLCQGVVSTPVCPNGPGNCQVSLRDLFDRAVMVSHYIHDLSS"
                                   + "EMFNEFDKRYAQGKGFITMALNSCHTSSLPTPEDKEQAQQTHHEVLMSLILGLLRSWNDPLYHL";

            Identifier      identifier          = new LocalIdentifier("123");
            Header          header              = new Header(identifier);
            IActualSequence sequence            = AminoAcidSequence.Parse(inputSequence);
            var             singleFASTAFileData = new Sequence(header, sequence);

            _ = singleFASTAFileData.ToInterleavedLines(0).ToList();
        }
コード例 #11
0
 public static Peptide PeptideFromSequence(AminoAcidSequence aminoAcidNameSequence, PeptideBuilderOptions options = null)
 {
     if (options == null)
     {
         options = new PeptideBuilderOptions();
     }
     if (options.BuildMolecule)
     {
         var aminoAcidReferences = aminoAcidNameSequence
                                   .Select(sequenceItem => AminoAcidLibrary.Get(sequenceItem.AminoAcidName, sequenceItem.ResidueNumber));
         return(PeptideFromAminoAcids(aminoAcidReferences));
     }
     else
     {
         var aminoAcidReferences = aminoAcidNameSequence
                                   .Select((aa, idx) => new AminoAcidReference(aa.AminoAcidName, aa.ResidueNumber, null, new List <uint>(), 0, 0))
                                   .ToList();
         return(new Peptide(new MoleculeReference(new Molecule()), aminoAcidReferences));
     }
 }
コード例 #12
0
        private void SetModifications(PhosphoRSInput input)
        {
            _modifications = input.Modifications;

            _aminoAcidModifications = _modifications.Select(
                modification => new AminoAcidModification(
                    modification.Symbol,
                    modification.Name,
                    modification.Abbreviation,
                    modification.NeutralLossAbbreviation,
                    modification.MassDelta,
                    modification.NeutralLoss,
                    AminoAcidSequence.ParseAASequence(modification.TargetAminoAcids)
                    )
                ).ToList();

            _phosphoModification = _aminoAcidModifications
                                   .Where(modification => modification.ID == _options.PhosphorylationSymbol)
                                   .First();

            _phosphoTargetAminoAcids = _phosphoModification.TargetAminoAcids
                                       .Select(a => a.OneLetterCode)
                                       .ToArray();
        }
コード例 #13
0
 public void Parse_ShouldRejectInvalidCharacterAtEnd()
 {
     _ = AminoAcidSequence.Parse("ABC2");
 }
コード例 #14
0
        private void SetSpectra(PhosphoRSInput input)
        {
            _spectra = input.Spectra;

            _spectrumMap    = new Dictionary <int, Spectrum>();
            _peptideMap     = new Dictionary <int, Peptide>();
            _phosphoSiteMap = new Dictionary <int, List <int> >();

            _items = new List <Tuple <PeptideSpectrumMatch, List <Tuple <int, List <int> > > > >();

            var count = 0;

            foreach (var spectrum in input.Spectra)
            {
                var rank = 0;
                foreach (var peptide in spectrum.IdentifiedPhosphorPeptides)
                {
                    if (_options.MaxHitRank > 0 && rank >= _options.MaxHitRank)
                    {
                        break;
                    }
                    rank += 1;

                    var isoformMap = new List <Tuple <int, List <int> > >();

                    var aas = AminoAcidSequence.Create(
                        peptide.ID,
                        peptide.Sequence,
                        _aminoAcidModifications,
                        peptide.Modification
                        );

                    var psm = new PeptideSpectrumMatch(
                        peptide.ID,
                        spectrum.ActivationType,
                        spectrum.PrecursorCharge,
                        1,
                        spectrum.Peaks.ToArray(),
                        aas
                        );

                    var phosphoCount = peptide.Modification
                                       .Skip(2).SkipLast(2)
                                       .Where(c => c == _options.PhosphorylationSymbol)
                                       .Count();

                    if (phosphoCount == 0)
                    {
                        continue;
                    }

                    var targetSites = peptide.Sequence
                                      .Select((c, i) => _phosphoTargetAminoAcids.Contains(c) ? i : -1)
                                      .Where(i => i >= 0)
                                      .ToList();

                    targetSites.Combinations(phosphoCount).Take(_options.MaxIsoformCount).ForEach(sites =>
                    {
                        var list = sites.ToList();
                        isoformMap.Add(
                            new Tuple <int, List <int> >(
                                count,
                                list
                                )
                            );

                        _spectrumMap.Add(count, spectrum);
                        _peptideMap.Add(count, peptide);
                        _phosphoSiteMap.Add(count, list);
                        count += 1;
                    });

                    _items.Add(Tuple.Create <PeptideSpectrumMatch, List <Tuple <int, List <int> > > >(
                                   psm,
                                   isoformMap
                                   ));
                }
            }
        }
コード例 #15
0
 public void Parse_ShouldRejectNullString()
 {
     _ = AminoAcidSequence.Parse(null);
 }
コード例 #16
0
 public void Parse_ShouldRejectInvalidCharacterAtStart()
 {
     _ = AminoAcidSequence.Parse("2ABC");
 }
コード例 #17
0
        public void Parse_ShouldConvertLowercaseSequenceToUppercase()
        {
            var aminoAcidSequenceData = AminoAcidSequence.Parse("abc");

            Assert.AreEqual("ABC", aminoAcidSequenceData.Characters);
        }
コード例 #18
0
        public void Parse_ShouldConvertMultilineSequenceToSingleLine()
        {
            var aminoAcidSequenceData = AminoAcidSequence.Parse("ABC\nDEF");

            Assert.AreEqual("ABCDEF", aminoAcidSequenceData.Characters);
        }