Skip to content
Snippets Groups Projects
Commit 45d06278 authored by felmer's avatar felmer
Browse files

Test fixed, dead classes removed

SVN: 23149
parent ffdb3cb2
No related branches found
No related tags found
No related merge requests found
/*
* Copyright 2009 ETH Zuerich, CISD
*
* 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 ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.application.columns;
import java.util.Map;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractColumnDefinition;
import ch.systemsx.cisd.openbis.generic.shared.basic.GridRowModel;
import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinInfo;
public final class InternalAbundanceColumnDefinition extends AbstractColumnDefinition<ProteinInfo>
{
private static final Double ZERO = new Double(1e-40);
private long sampleID;
private Map<String, String> properties;
// GWT only
public InternalAbundanceColumnDefinition()
{
super();
}
public InternalAbundanceColumnDefinition(String headerTextOrNull,
Map<String, String> propertiesOrNull, int width, boolean isHidden, long sampleID)
{
super(headerTextOrNull, width, isHidden, true, false);
this.properties = propertiesOrNull;
this.sampleID = sampleID;
}
public String getIdentifier()
{
return "abundance-" + Long.toString(sampleID);
}
@Override
protected String tryGetValue(ProteinInfo entity)
{
Double abundance = tryToGetAbundance(entity);
return abundance == null ? null : Double.toString(abundance);
}
@Override
public Comparable<?> tryGetComparableValue(GridRowModel<ProteinInfo> rowModel)
{
Double abundance = tryToGetAbundance(rowModel.getOriginalObject());
return abundance == null ? ZERO : abundance;
}
@Override
public String tryToGetProperty(String key)
{
return properties == null ? null : properties.get(key);
}
private Double tryToGetAbundance(ProteinInfo entity)
{
Map<Long, Double> abundances = entity.getAbundances();
if (abundances == null)
{
return null;
}
return abundances.get(sampleID);
}
}
\ No newline at end of file
/*
* Copyright 2009 ETH Zuerich, CISD
*
* 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 ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.application.columns;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractColumnDefinitionKind;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.IColumnDefinitionKind;
import ch.systemsx.cisd.openbis.generic.shared.basic.GridRowModel;
import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.application.Dict;
import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinInfo;
/**
* @author Franz-Josef Elmer
*/
public enum ProteinColDefKind implements IColumnDefinitionKind<ProteinInfo>
{
ACCESSION_NUMBER(new AbstractColumnDefinitionKind<ProteinInfo>(Dict.ACCESSION_NUMBER)
{
@Override
public String tryGetValue(ProteinInfo entity)
{
return entity.getAccessionNumber();
}
}),
DESCRIPTION(new AbstractColumnDefinitionKind<ProteinInfo>(Dict.PROTEIN_DESCRIPTION)
{
@Override
public String tryGetValue(ProteinInfo entity)
{
return entity.getDescription();
}
}),
COVERAGE(new AbstractColumnDefinitionKind<ProteinInfo>(Dict.COVERAGE, 100, false, true)
{
@Override
public String tryGetValue(ProteinInfo entity)
{
return Double.toString(entity.getCoverage());
}
@Override
public Comparable<?> getComparableValue(GridRowModel<ProteinInfo> entity)
{
return entity.getOriginalObject().getCoverage();
}
}), ;
private final AbstractColumnDefinitionKind<ProteinInfo> columnDefinitionKind;
private ProteinColDefKind(AbstractColumnDefinitionKind<ProteinInfo> columnDefinitionKind)
{
this.columnDefinitionKind = columnDefinitionKind;
}
public String id()
{
return name();
}
public AbstractColumnDefinitionKind<ProteinInfo> getDescriptor()
{
return columnDefinitionKind;
}
}
/*
* Copyright 2009 ETH Zuerich, CISD
*
* 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 ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.server;
import java.util.List;
import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.openbis.generic.client.web.server.AbstractOriginalDataProviderWithoutHeaders;
import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IPhosphoNetXServer;
import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.AggregateFunction;
import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinInfo;
/**
*
*
* @author Franz-Josef Elmer
*/
class ListProteinOriginalDataProvider extends AbstractOriginalDataProviderWithoutHeaders<ProteinInfo>
{
private final IPhosphoNetXServer server;
private final String sessionToken;
private final TechId experimentID;
private final double falseDiscoveryRate;
private final AggregateFunction aggregateFunction;
private final String treatmentTypeCode;
private final boolean aggregateOnOriginal;
ListProteinOriginalDataProvider(IPhosphoNetXServer server, String sessionToken,
TechId experimentID, double falseDiscoveryRate, AggregateFunction function,
String treatmentTypeCode, boolean aggregateOnOriginal)
{
this.server = server;
this.sessionToken = sessionToken;
this.experimentID = experimentID;
this.falseDiscoveryRate = falseDiscoveryRate;
this.aggregateFunction = function;
this.treatmentTypeCode = treatmentTypeCode;
this.aggregateOnOriginal = aggregateOnOriginal;
}
@Override
public List<ProteinInfo> getFullOriginalData() throws UserFailureException
{
return server.listProteinsByExperiment(sessionToken, experimentID, falseDiscoveryRate,
aggregateFunction, treatmentTypeCode, aggregateOnOriginal);
}
}
...@@ -19,6 +19,7 @@ package ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.server; ...@@ -19,6 +19,7 @@ package ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.server;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
...@@ -190,6 +191,12 @@ public class PhosphoNetXClientServiceTest extends AbstractFileSystemTestCase ...@@ -190,6 +191,12 @@ public class PhosphoNetXClientServiceTest extends AbstractFileSystemTestCase
{ {
final TechId experimentID1 = new TechId(42L); final TechId experimentID1 = new TechId(42L);
final TechId experimentID2 = new TechId(4711L); final TechId experimentID2 = new TechId(4711L);
final AbundanceColumnDefinition colDef = new AbundanceColumnDefinition();
colDef.setSampleCode("S1");
Treatment treatment = new Treatment();
treatment.setType("type1");
treatment.setTypeCode("code");
colDef.setTreatments(Arrays.asList(treatment));
final double fdr1 = 0.125; final double fdr1 = 0.125;
final double fdr2 = 0.25; final double fdr2 = 0.25;
final AggregateFunction f1 = AggregateFunction.MAX; final AggregateFunction f1 = AggregateFunction.MAX;
...@@ -205,6 +212,15 @@ public class PhosphoNetXClientServiceTest extends AbstractFileSystemTestCase ...@@ -205,6 +212,15 @@ public class PhosphoNetXClientServiceTest extends AbstractFileSystemTestCase
context.checking(new Expectations() context.checking(new Expectations()
{ {
{ {
one(server).getAbundanceColumnDefinitionsForProteinByExperiment(SESSION_TOKEN,
experimentID1, treatment1);
will(returnValue(Arrays.asList(colDef)));
one(server).getAbundanceColumnDefinitionsForProteinByExperiment(SESSION_TOKEN,
experimentID1, treatment2);
will(returnValue(Arrays.asList(colDef)));
one(server).getAbundanceColumnDefinitionsForProteinByExperiment(SESSION_TOKEN,
experimentID2, treatment1);
will(returnValue(Arrays.asList(colDef)));
one(server).listProteinsByExperiment(SESSION_TOKEN, experimentID1, fdr1, f1, one(server).listProteinsByExperiment(SESSION_TOKEN, experimentID1, fdr1, f1,
treatment1, false); treatment1, false);
will(returnValue(Arrays.asList(p1))); will(returnValue(Arrays.asList(p1)));
...@@ -239,7 +255,7 @@ public class PhosphoNetXClientServiceTest extends AbstractFileSystemTestCase ...@@ -239,7 +255,7 @@ public class PhosphoNetXClientServiceTest extends AbstractFileSystemTestCase
listAndCheckProteins(p4, experimentID1, fdr1, f2, treatment1, false); listAndCheckProteins(p4, experimentID1, fdr1, f2, treatment1, false);
listAndCheckProteins(p5, experimentID1, fdr1, f1, treatment2, false); listAndCheckProteins(p5, experimentID1, fdr1, f1, treatment2, false);
listAndCheckProteins(p6, experimentID1, fdr1, f1, treatment1, true); listAndCheckProteins(p6, experimentID1, fdr1, f1, treatment1, true);
assertEquals(13, cacheFolder.listFiles().length); assertEquals(19, cacheFolder.listFiles().length);
context.assertIsSatisfied(); context.assertIsSatisfied();
} }
...@@ -267,6 +283,7 @@ public class PhosphoNetXClientServiceTest extends AbstractFileSystemTestCase ...@@ -267,6 +283,7 @@ public class PhosphoNetXClientServiceTest extends AbstractFileSystemTestCase
ProteinInfo protein = new ProteinInfo(); ProteinInfo protein = new ProteinInfo();
protein.setId(new TechId(id)); protein.setId(new TechId(id));
protein.setDescription("Protein " + id); protein.setDescription("Protein " + id);
protein.setAbundances(new HashMap<Long, Double>());
return protein; return protein;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment