public ThermoResult correctMeltingResults(Environment environment) {

    double Tm = correctTemperature(environment);
    environment.setResult(Tm);

    return environment.getResult();
  }
  /**
   * corrects the computed melting temperature depending on the environment.
   *
   * @param environment
   * @return double corrected melting temperature
   */
  protected double correctTemperature(Environment environment) {
    OptionManagement.logMessage("\n The magnesium correction is");
    OptionManagement.logMethodName(methodName);
    OptionManagement.logMessage(temperatureCorrection);
    OptionManagement.logMessage("where : ");
    OptionManagement.logMessage("b = " + this.b);
    OptionManagement.logMessage("c = " + this.c);
    OptionManagement.logMessage("e = " + this.e);
    OptionManagement.logMessage("f = " + this.f);
    displayVariable();

    double Mg = environment.getMg() - environment.getDNTP();
    double square = Math.log(Mg) * Math.log(Mg);
    double Fgc = environment.getSequences().computesPercentGC() / 100.0;

    double TmInverse =
        1.0 / (environment.getResult().getTm() + 273.15)
            + this.a
            + this.b * Math.log(Mg)
            + Fgc * (this.c + this.d * Math.log(Mg))
            + 1.0
                / (2.0 * ((double) environment.getSequences().getDuplexLength() - 1.0))
                * (this.e + this.f * Math.log(Mg) + this.g * square);
    return (1.0 / TmInverse) - 273.15;
  }
  public ThermoResult correctMeltingResults(Environment environment) {

    OptionManagement.logMessage("\n The sodium correction is");
    OptionManagement.logMethodName(methodName);
    OptionManagement.logMessage(temperatureCorrection);

    double NaEq = Helper.computesNaEquivalent(environment);
    double Fgc = environment.getSequences().computesPercentGC() / 100.0;

    double TmInverse =
        1.0 / (environment.getResult().getTm() + 273.15)
            + (3.85 * Fgc - 6.18) * 1 / 100000 * Math.log(NaEq);
    environment.setResult((1.0 / TmInverse) - 273.15);

    return environment.getResult();
  }
  public boolean isApplicable(Environment environment) {
    boolean isApplicable = true;
    if (environment.getMg() == 0) {
      OptionManagement.logWarning(
          "\n The magnesium concentration must be a positive numeric value.");
      isApplicable = false;
    } else if (environment.getMg() < 0.0005 || environment.getMg() > 0.6) {
      OptionManagement.logWarning(
          "\n The magnesium correction of Owczarzy et al. "
              + "(2008) is accurate in the magnesium concentration range of 0.5mM to 600mM.");
    }

    if (environment.getHybridization().equals("dnadna") == false) {
      OptionManagement.logWarning(
          "\n The magnesium correction of Owczarzy et al. "
              + "(2008) is originally established for DNA duplexes.");
    }
    return isApplicable;
  }
  public boolean isApplicable(Environment environment) {
    boolean isApplicable = true;
    double NaEq = Helper.computesNaEquivalent(environment);

    if (NaEq == 0) {
      OptionManagement.logWarning("\n The sodium concentration must be strictly positive.");
      isApplicable = false;
    }

    if (environment.getHybridization().equals("dnadna") == false) {

      OptionManagement.logWarning(
          "\n The sodium correction of Owczarzy et al. (2004) 20 is originally established for "
              + "DNA duplexes.");
    }

    return isApplicable;
  }