DifferentialProfileComparator implements Comparator<T> { public double getExpressionLevelFoldChange(DifferentialProfile<?, ?> differentialProfile) { double minExpressionLevelOnNonSelectedQueryContrasts = differentialProfile.getMaxExpressionLevelOn(nonSelectedQueryContrasts); double averageExpressionLevelOnSelectedQueryContrasts = differentialProfile.getAverageExpressionLevelOn(selectedQueryContrasts); if (averageExpressionLevelOnSelectedQueryContrasts == 0) { return minExpressionLevelOnNonSelectedQueryContrasts / Double.MIN_VALUE; } return minExpressionLevelOnNonSelectedQueryContrasts / averageExpressionLevelOnSelectedQueryContrasts; } DifferentialProfileComparator(boolean isSpecific, Collection<Contrast> selectedQueryContrasts,
                                         Collection<Contrast> allQueryContrasts, Regulation regulation); static DifferentialProfileComparator<Prof> create(
            DifferentialProfileStreamOptions options); @Override int compare(T firstProfile, T otherProfile); double getExpressionLevelFoldChange(DifferentialProfile<?, ?> differentialProfile);  }
@Test public void testGetExpressionLevelFoldChangeOn() { when(profileMock1.getMaxExpressionLevelOn(nonSelectedContrasts)).thenReturn(0.04); when(profileMock1.getAverageExpressionLevelOn(selectedContrasts)).thenReturn(0.025); assertThat(subject.getExpressionLevelFoldChange(profileMock1), is(1.5999999999999999)); when(profileMock1.getMaxExpressionLevelOn(nonSelectedContrasts)).thenReturn(0.05D); when(profileMock1.getAverageExpressionLevelOn(selectedContrasts)).thenReturn(0.025); assertThat(subject.getExpressionLevelFoldChange(profileMock1), is(2D)); when(profileMock1.getMaxExpressionLevelOn(nonSelectedContrasts)).thenReturn(0.02); when(profileMock1.getAverageExpressionLevelOn(selectedContrasts)).thenReturn(0.01); assertThat(subject.getExpressionLevelFoldChange(profileMock1), is(2D)); }
@Test public void testGetExpressionLevelFoldChangeOnWhenAllContrastsAreSelected() { subject = new DifferentialProfileComparator<>(true, selectedContrasts, allContrasts, Regulation.UP); when(profileMock1.getMaxExpressionLevelOn(nonSelectedContrasts)).thenReturn(0.05); when(profileMock1.getAverageExpressionLevelOn(selectedContrasts)).thenReturn(0.025); assertThat(subject.getExpressionLevelFoldChange(profileMock1), is(2D)); }