Exemplo n.º 1
0
        public void IncorrectNegativeParseTest()
        {
            // No longer accepting Unimod format
            string formulaString = "C6H12N-O";

            Assert.IsFalse(ChemicalFormula.TryParseString(formulaString, _elementProvider, out _));
        }
Exemplo n.º 2
0
 /// <summary>Gets the modification.</summary>
 /// <param name="descriptor">The descriptor.</param>
 /// <returns></returns>
 public IProteoformMassDelta?GetModification(IProFormaDescriptor descriptor)
 {
     if (ChemicalFormula.TryParseString(descriptor.Value, this._elementProvider, out IChemicalFormula chemicalFormula))
     {
         return(new FormulaModification(chemicalFormula));
     }
     else
     {
         throw new ProteoformModificationLookupException($"Could not parse formula string for descriptor {descriptor}");
     }
 }
Exemplo n.º 3
0
        private IChemicalFormula SimpleParseTest(string formulaString, params Tuple <string, int>[] elements)
        {
            bool success = ChemicalFormula.TryParseString(formulaString, _elementProvider, out IChemicalFormula chemicalFormula);

            Assert.IsTrue(success);
            Assert.IsNotNull(chemicalFormula);

            IReadOnlyCollection <IEntityCardinality <IElement> > elementCollection = chemicalFormula.GetElements();

            Assert.AreEqual(elements.Length, elementCollection.Count, "Element Count");

            foreach (var(symbol, count) in elements)
            {
                IEntityCardinality <IElement> h = elementCollection.SingleOrDefault(e => e.Entity.Symbol == symbol);
                Assert.IsNotNull(h, $"For element '{symbol}{count}'");
                Assert.AreEqual(count, h.Count, $"For element '{symbol}{count}'");
            }

            return(chemicalFormula);
        }