Class ElementTable

java.lang.Object
java.util.AbstractMap<K,V>
java.util.EnumMap<Element,Integer>
org.lifstools.jgoslin.domain.ElementTable
All Implemented Interfaces:
Serializable, Cloneable, Map<Element,Integer>

public final class ElementTable extends EnumMap<Element,Integer>
Accounting table for chemical element frequency. This is used to calculate sum formulas and total masses for a given chemical element distribution, e.g. in a lipid.
Author:
Dominik Kopczynski, Nils Hoffmann
See Also:
  • Constructor Details

    • ElementTable

      public ElementTable()
      Create a new element table.
  • Method Details

    • of

      public static ElementTable of(Map.Entry<Element,Integer>... entries)
      Create a new element table from the provided entries.
      Parameters:
      entries - the entries
      Returns:
      a new element table.
    • add

      public void add(ElementTable elements)
      Add all elements and counts to those in this element table.
      Parameters:
      elements - the table to add to this one.
    • add

      public void add(ElementTable elements, int multiplier)
      Add all alements and counts to those in this element table, but use the count argument to multiply count values in the provided table.
      Parameters:
      elements -
      multiplier -
    • copy

      public ElementTable copy()
      Copy all entries in this element table. The copy will be completely independent of this instance.
      Returns:
      a copy of this element table.
    • getSumFormula

      Returns the sum formula for all elements in this table.
      Returns:
      the sum formula. Returns an empty string if the table is empty.
    • getMass

      public Double getMass(Element element)
      Returns the individual total mass for the provided element.
      Parameters:
      element - the element to calculate the total mass for.
      Returns:
      the total mass for the given element, or 0.
    • getMass

      public Double getMass()
      Returns the total summed mass per number of elements.
      Returns:
      the total summed mass for this element table. Returns 0 if the table is empty.
    • getChargedMass

      public Double getChargedMass(int charge)
      Returns the total summed mass per number of elements, corrected for charge counts * electron rest mass.
      Parameters:
      charge - the charge of the molecule
      Returns:
      the total summed mass for this element table. Returns 0 if the table is empty.