/*
 *                      Nividic development code
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the microarray platform
 * of the cole Normale Suprieure and the individual authors.
 * These should be listed in @author doc comments.
 *
 * For more information on the Nividic project and its aims,
 * or to join the Nividic mailing list, visit the home page
 * at:
 *
 *      http://www.transcriptome.ens.fr/nividic
 *
 */

package fr.ens.transcriptome.nividic.om.filters;

import fr.ens.transcriptome.nividic.om.ExpressionMatrix;
import fr.ens.transcriptome.nividic.om.ExpressionMatrixRuntimeException;

/**
 * This class implements a filter for filtering using the value of a double row
 * of the matrix
 * @author Lory Montout
 * @author Laurent Jourdren
 */
public class ExpressionMatrixNARowFilter extends ExpressionMatrixRowFilter {

  private static final double RATE_DEFAULT = 2.0 / 3.0;

  private double rate = RATE_DEFAULT;

  /**
   * Test the values of a Row.
   * @param values Values to test
   * @return true if the values must be selected
   * @throws ExpressionMatrixRuntimeException if ratioValues is null
   */
  public boolean testRow(final double[] values)
      throws ExpressionMatrixRuntimeException {

    if (values == null)
      throw new ExpressionMatrixRuntimeException("values is null");

    final int size = values.length;

    int count = 0;

    for (int i = 0; i < size; i++) {
      if (Double.isNaN(values[i]))
        count++;
    }

    if (((double) count / (double) size) >= getRate())
      return false;

    return true;
  }

  /**
   * Get the dimension to filter.
   * @return The dimension to filter
   */
  public String getDimensionToFilter() {

    return ExpressionMatrix.DIMENSION_M;
  }

  /**
   * Test if filtered identifiers must be removed.
   */
  public boolean removeFilteredRows() {

    return false;
  }

  /**
   * Get the rate of the filter.
   * @return Returns the rate
   */
  public double getRate() {

    return rate;
  }

  /**
   * Set the rate of the filter.
   * @param rate The rate to set
   */
  public void setRate(final double rate) {

    this.rate = rate;
  }

  //
  // Constructor
  //

  /**
   * Default constructor.
   */
  public ExpressionMatrixNARowFilter() {
  }

  /**
   * Constructor.
   * @param rate The rate of the filter
   */
  public ExpressionMatrixNARowFilter(final double rate) {

    setRate(rate);
  }

}
@@ -1727,13 +1727,29 @@
     
-if ((
+final double ratio = 
 (dou
@@ -1778,12 +1778,26 @@
 size
-) %3E=
+;%0A%0A    if (ratio %3C
  get
@@ -1817,20 +1817,19 @@
  return 
-fals
+tru
 e;%0A%0A    
@@ -1835,19 +1835,20 @@
  return 
-tru
+fals
 e;%0A  %7D%0A%0A

Fix : indentation