/*
 * The Gemma project.
 * 
 * Copyright (c) 2006-2010 University of British Columbia
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package ubic.gemma.model.analysis.expression.diff;

/**
 * @see ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysisResult
 * @version $Id$
 */
public class DifferentialExpressionAnalysisResultImpl extends
        ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysisResult {
    /**
     * The serial version UID of this class. Needed for serialization.
     */
    private static final long serialVersionUID = 8952834115689524169L;

    private static int getBin( Double value ) {
        return ( int ) Math.min( 5, Math.floor( -Math.log10( value ) ) );
    }

    @Override
    public void setCorrectedPvalue( Double correctedPvalue ) {

        if ( correctedPvalue == null ) return;

        super.setCorrectedPvalue( correctedPvalue );

        /*
         * See bug 2013. Here we ensure that the bin is always set. The maximum value is 5, representing qvalues better
         * than 10e-5. 0.1-1 -> 0; 0.01-0.099 -> 1; 0.001-0.00999 -> 2; 0.0001- 0.000999 -> 3 etc. Thus "p<0.01" is
         * equivalent to "bin >=2"
         */
        this.setCorrectedPValueBin( getBin( correctedPvalue ) );
    }

    @Override
    public String toString() {
        return this.getProbe() + " p=" + String.format( "%g", this.getPvalue() );
    }

}
@@ -1931,9 +1931,1280 @@
 %0A    %7D%0A%0A
+    @Override%0A    public int hashCode() %7B%0A        if ( this.getId() != null ) return super.hashCode();%0A        final int prime = 31;%0A        int result = super.hashCode();%0A        result = prime * result + ( ( super.getProbe() == null ) ? 0 : super.getProbe().hashCode() );%0A        result = prime * result%0A                + ( ( super.getQuantitationType() == null ) ? 0 : super.getQuantitationType().hashCode() );%0A        return result;%0A    %7D%0A%0A    @Override%0A    public boolean equals( Object obj ) %7B%0A        if ( this == obj ) return true;%0A%0A        if ( getClass() != obj.getClass() ) return false;%0A%0A        DifferentialExpressionAnalysisResult other = ( DifferentialExpressionAnalysisResult ) obj;%0A%0A        if ( this.getId() != null ) %7B%0A            return ( other.getId() == null %7C%7C !this.getId().equals( other.getId() ) );%0A        %7D%0A%0A        if ( super.getProbe() == null ) %7B%0A            if ( other.getProbe() != null ) return false;%0A        %7D else if ( !super.getProbe().equals( other.getProbe() ) ) return false;%0A%0A        if ( super.getQuantitationType() == null ) %7B%0A            if ( other.getQuantitationType() != null ) return false;%0A        %7D else if ( !super.getQuantitationType().equals( other.getQuantitationType() ) ) return false;%0A%0A        return true;%0A    %7D%0A
 %7D

implement better hashcode/equals