diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/etlserver/phosphonetx/AbundanceHandler.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/etlserver/phosphonetx/AbundanceHandler.java index c5ac2124a1751ea2fd46126917ced10b80a5fb31..d2e243a164a0a4353af6d9de8f9f033fc8997cb0 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/etlserver/phosphonetx/AbundanceHandler.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/etlserver/phosphonetx/AbundanceHandler.java @@ -38,10 +38,16 @@ class AbundanceHandler extends AbstractHandler { @Private static final String MZXML_FILENAME = "MZXML_FILENAME"; + private static final class SampleOrError + { + Sample sample; + String error; + } + private final IEncapsulatedOpenBISService openbisService; private final GroupIdentifier groupIdentifier; private final Experiment experiment; - private final Map<String, Sample> samples = new HashMap<String, Sample>(); + private final Map<String, SampleOrError> samplesOrErrors = new HashMap<String, SampleOrError>(); AbundanceHandler(IEncapsulatedOpenBISService openbisService, IProtDAO dao, GroupIdentifier groupIdentifier, Experiment experiment) @@ -68,16 +74,16 @@ class AbundanceHandler extends AbstractHandler private Sample getOrCreateSample(String parameterName, String proteinName) { - Sample sample = samples.get(parameterName); - if (sample == null) + SampleOrError sampleOrError = samplesOrErrors.get(parameterName); + if (sampleOrError == null) { SampleIdentifier sampleIdentifier = new SampleIdentifier(groupIdentifier, parameterName); SamplePE samplePE = openbisService.tryGetSampleWithExperiment(sampleIdentifier); - String permID; + sampleOrError = new SampleOrError(); if (samplePE != null) { - permID = samplePE.getPermId(); + sampleOrError.sample = getOrCreateSample(experiment, samplePE.getPermId()); } else { List<ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample> list = @@ -87,21 +93,22 @@ class AbundanceHandler extends AbstractHandler .getGroupCode(), null)); if (list == null || list.size() == 0) { - throw new UserFailureException("Protein '" + proteinName - + "' has an abundance value for an unidentified samples: " - + parameterName); - } - if (list.size() > 1) + sampleOrError.error = "an unidentified sample: " + parameterName; + } else if (list.size() > 1) { - throw new UserFailureException("Protein '" + proteinName - + "' has an abundance value for which " + list.size() - + " samples are found: " + parameterName); + sampleOrError.error = list.size() + " samples are found: " + parameterName; + } else + { + sampleOrError.sample = getOrCreateSample(experiment, list.get(0).getPermId()); } - permID = list.get(0).getPermId(); } - sample = getOrCreateSample(experiment, permID); - samples.put(parameterName, sample); + samplesOrErrors.put(parameterName, sampleOrError); + } + if (sampleOrError.error != null) + { + throw new UserFailureException("Protein '" + proteinName + + "' has an abundance value for " + sampleOrError.error); } - return sample; + return sampleOrError.sample; } } diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/ProteinByExperimentBrowserGrid.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/ProteinByExperimentBrowserGrid.java index a1b0361b19b893f6505f225514ceea0edfa3194b..d42359319d28347ee5b92e24ff1d56370751b7d9 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/ProteinByExperimentBrowserGrid.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/ProteinByExperimentBrowserGrid.java @@ -18,7 +18,6 @@ package ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.applicatio import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Set; import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; @@ -27,7 +26,6 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewConte import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.DispatcherHelper; import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.BaseEntityModel; import ch.systemsx.cisd.openbis.generic.client.web.client.application.renderer.LinkRenderer; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.AbstractColumnDefinition; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.IColumnDefinitionKind; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.IColumnDefinitionUI; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.AbstractSimpleBrowserGrid; @@ -42,6 +40,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind.ObjectKind; import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.IPhosphoNetXClientServiceAsync; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.application.columns.InternalAbundanceColumnDefinition; import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.application.columns.ProteinColDefKind; import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.AggregateFunction; import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ListProteinByExperimentCriteria; @@ -134,29 +133,7 @@ class ProteinByExperimentBrowserGrid extends AbstractSimpleBrowserGrid<ProteinIn } } final long sampleID = definition.getSampleID(); - columns.add(new AbstractColumnDefinition<ProteinInfo>(header, 100, false) - { - @Override - protected String tryGetValue(ProteinInfo entity) - { - Map<Long, Double> abundances = entity.getAbundances(); - if (abundances == null) - { - return null; - } - Double abundance = abundances.get(sampleID); - if (abundance == null) - { - return null; - } - return Double.toString(abundance); - } - - public String getIdentifier() - { - return "abundance-" + Long.toString(sampleID); - } - }); + columns.add(new InternalAbundanceColumnDefinition(header, 100, false, sampleID)); } definitions.addColumns(columns); definitions.setGridCellRendererFor(ProteinColDefKind.UNIPROT_ID.id(), LinkRenderer diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/columns/InternalAbundanceColumnDefinition.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/columns/InternalAbundanceColumnDefinition.java new file mode 100644 index 0000000000000000000000000000000000000000..05125c7e25fb6db55f5fa917b583224ecb1529cf --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/columns/InternalAbundanceColumnDefinition.java @@ -0,0 +1,62 @@ +/* + * 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.plugin.phosphonetx.client.web.client.dto.ProteinInfo; + +public final class InternalAbundanceColumnDefinition extends + AbstractColumnDefinition<ProteinInfo> +{ + private long sampleID; + + // GWT only + public InternalAbundanceColumnDefinition() + { + super(); + } + + public InternalAbundanceColumnDefinition(String headerTextOrNull, int width, + boolean isHidden, long sampleID) + { + super(headerTextOrNull, width, isHidden); + this.sampleID = sampleID; + } + + @Override + protected String tryGetValue(ProteinInfo entity) + { + Map<Long, Double> abundances = entity.getAbundances(); + if (abundances == null) + { + return null; + } + Double abundance = abundances.get(sampleID); + if (abundance == null) + { + return null; + } + return Double.toString(abundance); + } + + public String getIdentifier() + { + return "abundance-" + Long.toString(sampleID); + } +} \ No newline at end of file diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/dataaccess/IProteinQueryDAO.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/dataaccess/IProteinQueryDAO.java index 70f11f2cc16a6d67589214c9587aade4f39e1f46..e70e1b1ade338b73941e0e7bde6713de7b93495b 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/dataaccess/IProteinQueryDAO.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/dataaccess/IProteinQueryDAO.java @@ -40,7 +40,7 @@ public interface IProteinQueryDAO extends BaseQuery public DataSet<ProbabilityFDRMapping> getProbabilityFDRMapping(long dataSetID); @Select("select pr.id, pr.uniprot_id, pr.description, d.id as data_set_id, p.probability, " - + " a.value, samples.id as sample_id " + + " a.value as abundance, samples.id as sample_id " + "from identified_proteins as ip left join proteins as p on ip.prot_id = p.id " + "left join data_sets as d on p.dase_id = d.id " + "left join experiments as e on d.expe_id = e.id " diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/dto/ProteinReferenceWithProbability.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/dto/ProteinReferenceWithProbability.java index 380c6e921f436e3d6d9cfa5ebc8c362857d4fd0b..030e8b8e0a304b5f99d978b81e1fad1f737c0952 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/dto/ProteinReferenceWithProbability.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/dto/ProteinReferenceWithProbability.java @@ -31,8 +31,8 @@ public class ProteinReferenceWithProbability extends ProteinReference @ResultColumn("probability") private double probability; - @ResultColumn("value") - private double abundance; + @ResultColumn("abundance") + private Double abundance; @ResultColumn("sample_id") private Long sampleID; @@ -57,12 +57,12 @@ public class ProteinReferenceWithProbability extends ProteinReference this.probability = probability; } - public final double getAbundance() + public final Double getAbundance() { return abundance; } - public final void setAbundance(double abundance) + public final void setAbundance(Double abundance) { this.abundance = abundance; } diff --git a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/etlserver/phosphonetx/ResultDataSetUploaderTest.java b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/etlserver/phosphonetx/ResultDataSetUploaderTest.java index c53c2590e385de840d132377e677414c6009b97b..fabb112611bd40e7b1616aa7d787a07256e2ec88 100644 --- a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/etlserver/phosphonetx/ResultDataSetUploaderTest.java +++ b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/etlserver/phosphonetx/ResultDataSetUploaderTest.java @@ -338,7 +338,7 @@ public class ResultDataSetUploaderTest extends AssertJUnit } catch (UserFailureException ex) { AssertionUtil.assertContains("Protein '" + PROTEIN_NAME1 - + "' has an abundance value for an unidentified samples: " + + "' has an abundance value for an unidentified sample: " + upperCaseParameterName, ex.getMessage()); }