コード例 #1
0
 public Isotope getIsotope(int massNumber) {
   Iterator<Isotope> isotopeIterator = isotopes.iterator();
   Isotope isotope;
   while (isotopeIterator.hasNext()) {
     isotope = isotopeIterator.next();
     if (isotope.getMassNumber() == massNumber) {
       return isotope;
     }
   }
   return null;
 }
コード例 #2
0
 public TreeSet<Isotope> getNaturallyOccuringIsotopes() {
   TreeSet<Isotope> isotopes = new TreeSet<>();
   Iterator<Isotope> isotopeIterator = this.isotopes.iterator();
   Isotope isotope;
   while (isotopeIterator.hasNext()) {
     isotope = isotopeIterator.next();
     if (isotope.getAbundance() > 0) {
       isotopes.add(isotope);
     }
   }
   return isotopes;
 }
コード例 #3
0
 private Element(
     int atomicNumber,
     String name,
     String symbol,
     Collection<? extends Isotope> isotopes,
     Group group) {
   this.atomicNumber = atomicNumber;
   this.name = name;
   this.symbol = symbol;
   this.isotopes = new TreeSet<>();
   for (Isotope isotope : isotopes) {
     this.isotopes.add(isotope.withElement(this));
   }
   this.group = group;
 }
コード例 #4
0
  public double getMonoisotopicMass() {
    if (isotopes.isEmpty()) return 0;

    Iterator<Isotope> isotopeIterator = isotopes.iterator();
    Isotope isotope;
    Isotope mostAbundant = isotopeIterator.next();

    while (isotopeIterator.hasNext()) {
      isotope = isotopeIterator.next();
      if (isotope.getAbundance() > mostAbundant.getAbundance()) {
        mostAbundant = isotope;
      }
    }

    return mostAbundant.getMass();
  }
コード例 #5
0
  public double getVariance() {
    double average = getAverageMass();
    double difference;
    double variance = 0;
    double totalAbundance = 0;

    Iterator<Isotope> isotopeIterator = isotopes.iterator();
    Isotope isotope;
    while (isotopeIterator.hasNext()) {
      isotope = isotopeIterator.next();
      difference = isotope.getMass() - average;
      variance += difference * difference * isotope.getAbundance();
      totalAbundance += isotope.getAbundance();
    }

    return variance / totalAbundance;
  }
コード例 #6
0
  public double getAverageMass() {
    double mass = 0;
    Iterator<Isotope> isotopeIterator = isotopes.iterator();
    Isotope isotope;

    if (isNaturallyOccurring()) {
      while (isotopeIterator.hasNext()) {
        isotope = isotopeIterator.next();
        mass += isotope.getMass() * isotope.getAbundance();
      }
      return mass;
    }

    while (isotopeIterator.hasNext()) {
      isotope = isotopeIterator.next();
      mass += isotope.getMass();
    }
    return mass / isotopes.size();
  }