From bac2fb852e570d2b317751a6d54d7bb3dafe3e3a Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Tue, 14 Jul 2009 09:14:05 +0000 Subject: [PATCH] LMS-1028 ProteinViewer: DataSetProteinGrid added SVN: 11738 --- .../web/client/IPhosphoNetXClientService.java | 8 ++ .../IPhosphoNetXClientServiceAsync.java | 10 ++ .../application/DataSetProteinGrid.java | 117 ++++++++++++++++++ .../client/web/client/application/Dict.java | 4 + .../PhosphoNetXDisplayTypeIDGenerator.java | 1 + .../web/client/application/ProteinViewer.java | 18 +-- .../columns/DataSetProteinColDefKind.java | 77 ++++++++++++ ...oteinByExperimentAndReferenceCriteria.java | 56 +++++++++ .../web/public/phosphonetx-dictionary.js | 4 + .../ListDataSetProteinDataProvider.java | 55 ++++++++ .../web/server/PhosphoNetXClientService.java | 17 +++ .../phosphonetx/server/PhosphoNetXServer.java | 56 ++++----- .../server/PhosphoNetXServerLogger.java | 9 ++ .../business/BusinessObjectFactory.java | 10 ++ .../server/business/DataSetProteinTable.java | 76 ++++++++++++ .../business/IBusinessObjectFactory.java | 4 + .../server/business/IDataSetProteinTable.java | 36 ++++++ .../business/IProteinSequenceTable.java | 37 ++++++ .../server/business/ProteinSequenceTable.java | 109 ++++++++++++++++ .../server/dataaccess/IProteinQueryDAO.java | 13 +- .../shared/IPhosphoNetXServer.java | 8 ++ .../shared/basic/dto/DataSetProtein.java | 107 ++++++++++++++++ .../shared/basic/dto/ProteinByExperiment.java | 15 --- .../shared/basic/dto/ProteinSequence.java | 12 ++ .../shared/dto/IdentifiedProtein.java | 12 +- .../phosphonetx/shared/dto/Sequence.java | 13 ++ 26 files changed, 818 insertions(+), 66 deletions(-) create mode 100644 rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/DataSetProteinGrid.java create mode 100644 rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/columns/DataSetProteinColDefKind.java create mode 100644 rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/dto/ListProteinByExperimentAndReferenceCriteria.java create mode 100644 rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/ListDataSetProteinDataProvider.java create mode 100644 rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/DataSetProteinTable.java create mode 100644 rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/IDataSetProteinTable.java create mode 100644 rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/IProteinSequenceTable.java create mode 100644 rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/ProteinSequenceTable.java create mode 100644 rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/basic/dto/DataSetProtein.java diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/IPhosphoNetXClientService.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/IPhosphoNetXClientService.java index 027f27bf771..0c11144c580 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/IPhosphoNetXClientService.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/IPhosphoNetXClientService.java @@ -21,9 +21,11 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ResultSet; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TableExportCriteria; import ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ListProteinByExperimentAndReferenceCriteria; import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ListProteinByExperimentCriteria; import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ListProteinSequenceCriteria; import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ProteinInfo; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.DataSetProtein; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinByExperiment; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinSequence; @@ -49,4 +51,10 @@ public interface IPhosphoNetXClientService extends IClientService public String prepareExportProteinSequences(TableExportCriteria<ProteinSequence> exportCriteria) throws UserFailureException; + public ResultSet<DataSetProtein> listProteinsByExperimentAndReference( + ListProteinByExperimentAndReferenceCriteria criteria) throws UserFailureException; + + public String prepareExportDataSetProteins(TableExportCriteria<DataSetProtein> exportCriteria) + throws UserFailureException; + } diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/IPhosphoNetXClientServiceAsync.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/IPhosphoNetXClientServiceAsync.java index a876608648f..2baa98ab4fd 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/IPhosphoNetXClientServiceAsync.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/IPhosphoNetXClientServiceAsync.java @@ -22,9 +22,11 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.IClientServiceAsync; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ResultSet; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TableExportCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ListProteinByExperimentAndReferenceCriteria; import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ListProteinByExperimentCriteria; import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ListProteinSequenceCriteria; import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ProteinInfo; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.DataSetProtein; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinByExperiment; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinSequence; @@ -55,4 +57,12 @@ public interface IPhosphoNetXClientServiceAsync extends IClientServiceAsync public void prepareExportProteinSequences(TableExportCriteria<ProteinSequence> exportCriteria, AsyncCallback<String> callback); + /** @see IPhosphoNetXClientService#listProteinsByExperimentAndReference(ListProteinByExperimentAndReferenceCriteria) */ + public void listProteinsByExperimentAndReference( + ListProteinByExperimentAndReferenceCriteria criteria, + AsyncCallback<ResultSet<DataSetProtein>> callback); + + /** @see IPhosphoNetXClientService#prepareExportDataSetProteins(TableExportCriteria) */ + public void prepareExportDataSetProteins(TableExportCriteria<DataSetProtein> exportCriteria, + AsyncCallback<String> callback); } \ No newline at end of file diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/DataSetProteinGrid.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/DataSetProteinGrid.java new file mode 100644 index 00000000000..52eb6a92aac --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/DataSetProteinGrid.java @@ -0,0 +1,117 @@ +/* + * 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; + +import java.util.List; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericConstants; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; +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.grid.AbstractSimpleBrowserGrid; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IDisposableComponent; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DefaultResultSetConfig; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Experiment; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.IColumnDefinition; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ResultSet; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TableExportCriteria; +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.IPhosphoNetXClientServiceAsync; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.application.columns.DataSetProteinColDefKind; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ListProteinByExperimentAndReferenceCriteria; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.DataSetProtein; + +/** + * + * + * @author Franz-Josef Elmer + */ +class DataSetProteinGrid extends AbstractSimpleBrowserGrid<DataSetProtein> +{ + private static final String PREFIX = GenericConstants.ID_PREFIX + "data-set-protein-browser"; + + public static final String BROWSER_ID = PREFIX + "_main"; + + public static final String GRID_ID = PREFIX + "_grid"; + + static IDisposableComponent create(IViewContext<IPhosphoNetXClientServiceAsync> viewContext, + Experiment experimentOrNull, TechId proteinReferenceID) + { + return new DataSetProteinGrid(viewContext, experimentOrNull, proteinReferenceID) + .asDisposableWithoutToolbar(); + } + + private static String createWidgetID(Experiment experimentOrNull, TechId proteinReferenceID) + { + return "-" + (experimentOrNull == null ? "" : experimentOrNull.getIdentifier() + "-") + + proteinReferenceID; + } + + private final IViewContext<IPhosphoNetXClientServiceAsync> specificViewContext; + + private ListProteinByExperimentAndReferenceCriteria criteria; + + private DataSetProteinGrid(IViewContext<IPhosphoNetXClientServiceAsync> viewContext, + Experiment experimentOrNull, TechId proteinReferenceID) + { + super(viewContext.getCommonViewContext(), BROWSER_ID + + createWidgetID(experimentOrNull, proteinReferenceID), GRID_ID + + createWidgetID(experimentOrNull, proteinReferenceID), true); + specificViewContext = viewContext; + criteria = new ListProteinByExperimentAndReferenceCriteria(); + if (experimentOrNull != null) + { + criteria.setExperimentID(new TechId(experimentOrNull.getId())); + } + criteria.setProteinReferenceID(proteinReferenceID); + setDisplayTypeIDGenerator(PhosphoNetXDisplayTypeIDGenerator.DATA_SET_PROTEIN_BROWSER_GRID); + } + + @Override + protected IColumnDefinitionKind<DataSetProtein>[] getStaticColumnsDefinition() + { + return DataSetProteinColDefKind.values(); + } + + @Override + protected List<IColumnDefinition<DataSetProtein>> getInitialFilters() + { + return asColumnFilters(new DataSetProteinColDefKind[] {}); + } + + @Override + protected void listEntities(DefaultResultSetConfig<String, DataSetProtein> resultSetConfig, + AbstractAsyncCallback<ResultSet<DataSetProtein>> callback) + { + criteria.copyPagingConfig(resultSetConfig); + specificViewContext.getService().listProteinsByExperimentAndReference(criteria, callback); + } + + @Override + protected void prepareExportEntities(TableExportCriteria<DataSetProtein> exportCriteria, + AbstractAsyncCallback<String> callback) + { + specificViewContext.getService().prepareExportDataSetProteins(exportCriteria, callback); + } + + public DatabaseModificationKind[] getRelevantModifications() + { + return new DatabaseModificationKind[0]; + } + +} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/Dict.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/Dict.java index d6cfad93f96..ee7668f7ee6 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/Dict.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/Dict.java @@ -39,6 +39,10 @@ public class Dict public static final String DATABASE_NAME_AND_VERSION = "database_name_and_version"; public static final String SEQUENCE = "sequence"; public static final String SEQUENCES = "sequences"; + public static final String DATA_SET_PROTEINS = "data_set_proteins"; + public static final String DATA_SET_PERM_ID = "data_set_perm_id"; + public static final String PEPTIDE_COUNT = "peptide_count"; + public static final String SEQUENCE_NAME = "sequence_name"; diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/PhosphoNetXDisplayTypeIDGenerator.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/PhosphoNetXDisplayTypeIDGenerator.java index 3c94d22a076..731e37132f6 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/PhosphoNetXDisplayTypeIDGenerator.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/PhosphoNetXDisplayTypeIDGenerator.java @@ -29,6 +29,7 @@ public enum PhosphoNetXDisplayTypeIDGenerator implements IDisplayTypeIDGenerator { PROTEIN_BY_EXPERIMENT_BROWSER_GRID("protein-by-experiment-browser-grid"), PROTEIN_SEQUENCE_BROWSER_GRID("protein-sequence-browser-grid"), + DATA_SET_PROTEIN_BROWSER_GRID("data-set-protein-browser-grid"), ; private final String genericNameOrPrefix; diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/ProteinViewer.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/ProteinViewer.java index 1d5b16eb297..1a11f8861bf 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/ProteinViewer.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/ProteinViewer.java @@ -93,8 +93,7 @@ public class ProteinViewer extends private final IViewContext<IPhosphoNetXClientServiceAsync> viewContext; private final Experiment experimentOrNull; - private final TechId experimentID; - private final TechId proteinreferenceID; + private final TechId proteinReferenceID; private ProteinViewer(IViewContext<IPhosphoNetXClientServiceAsync> viewContext, Experiment experimentOrNull, TechId proteinReferenceID) @@ -102,15 +101,17 @@ public class ProteinViewer extends super(viewContext, "", createWidgetID(proteinReferenceID), false); this.viewContext = viewContext; this.experimentOrNull = experimentOrNull; - this.experimentID = TechId.create(experimentOrNull); - this.proteinreferenceID = proteinReferenceID; + this.proteinReferenceID = proteinReferenceID; reloadAllData(); } private void reloadAllData() { - viewContext.getService().getProteinByExperiment(experimentID, proteinreferenceID, - new ProteinByExperimentCallback(viewContext, this)); + if (experimentOrNull != null) + { + viewContext.getService().getProteinByExperiment(new TechId(experimentOrNull.getId()), + proteinReferenceID, new ProteinByExperimentCallback(viewContext, this)); + } } private void recreateUI(ProteinByExperiment protein) @@ -134,7 +135,10 @@ public class ProteinViewer extends layoutData.setSize(400); add(contentPanel, layoutData); add(new BrowserSectionPanel(viewContext.getMessage(Dict.SEQUENCES), ProteinSequenceGrid - .create(viewContext, proteinreferenceID)), createRightBorderLayoutData()); + .create(viewContext, proteinReferenceID)), createRightBorderLayoutData()); + add(new BrowserSectionPanel(viewContext.getMessage(Dict.DATA_SET_PROTEINS), + DataSetProteinGrid.create(viewContext, experimentOrNull, proteinReferenceID)), + createBorderLayoutData(LayoutRegion.SOUTH)); layout(); } diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/columns/DataSetProteinColDefKind.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/columns/DataSetProteinColDefKind.java new file mode 100644 index 00000000000..9617da5e34c --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/application/columns/DataSetProteinColDefKind.java @@ -0,0 +1,77 @@ +/* + * 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.plugin.phosphonetx.client.web.client.application.Dict; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.DataSetProtein; + +/** + * + * + * @author Franz-Josef Elmer + */ +public enum DataSetProteinColDefKind implements IColumnDefinitionKind<DataSetProtein> +{ + DATA_SET_PERM_ID(new AbstractColumnDefinitionKind<DataSetProtein>(Dict.DATA_SET_PERM_ID, 200) + { + @Override + public String tryGetValue(DataSetProtein entity) + { + return entity.getDataSetPermID(); + } + }), + SEQUENCE_NAME(new AbstractColumnDefinitionKind<DataSetProtein>(Dict.SEQUENCE_NAME, 80) + { + @Override + public String tryGetValue(DataSetProtein entity) + { + return entity.getSequenceName(); + } + }), + + PEPTIDE_COUNT(new AbstractColumnDefinitionKind<DataSetProtein>(Dict.PEPTIDE_COUNT, 80) + { + @Override + public String tryGetValue(DataSetProtein entity) + { + return Integer.toString(entity.getPeptideCount()); + } + }), + + ; + + private final AbstractColumnDefinitionKind<DataSetProtein> columnDefinitionKind; + + private DataSetProteinColDefKind(AbstractColumnDefinitionKind<DataSetProtein> columnDefinitionKind) + { + this.columnDefinitionKind = columnDefinitionKind; + } + + public String id() + { + return name(); + } + + public AbstractColumnDefinitionKind<DataSetProtein> getDescriptor() + { + return columnDefinitionKind; + } + + +} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/dto/ListProteinByExperimentAndReferenceCriteria.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/dto/ListProteinByExperimentAndReferenceCriteria.java new file mode 100644 index 00000000000..e297544d3df --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/client/dto/ListProteinByExperimentAndReferenceCriteria.java @@ -0,0 +1,56 @@ +/* + * 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.dto; + +import com.google.gwt.user.client.rpc.IsSerializable; + +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DefaultResultSetConfig; +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.DataSetProtein; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class ListProteinByExperimentAndReferenceCriteria extends + DefaultResultSetConfig<String, DataSetProtein> implements IsSerializable +{ + private TechId experimentID; + private TechId proteinReferenceID; + + public final TechId getExperimentID() + { + return experimentID; + } + + public final void setExperimentID(TechId experimentID) + { + this.experimentID = experimentID; + } + + public final TechId getProteinReferenceID() + { + return proteinReferenceID; + } + + public final void setProteinReferenceID(TechId proteinReferenceID) + { + this.proteinReferenceID = proteinReferenceID; + } + +} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/public/phosphonetx-dictionary.js b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/public/phosphonetx-dictionary.js index 94845f627aa..50a8a9454f4 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/public/phosphonetx-dictionary.js +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/public/phosphonetx-dictionary.js @@ -18,6 +18,10 @@ var phosphonetx = { database_name_and_version: "Database", sequence: "Amino Acid Sequence", sequences: "Amino Acid Sequences", + data_set_proteins: "Data Sets", + data_set_perm_id: "Data Set", + peptide_count: "Peptides", + sequence_name: "Sequence", // LAST LINE: KEEP IT AT THE END lastline: "" // we need a line without a comma diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/ListDataSetProteinDataProvider.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/ListDataSetProteinDataProvider.java new file mode 100644 index 00000000000..7a32cc17440 --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/ListDataSetProteinDataProvider.java @@ -0,0 +1,55 @@ +/* + * 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.resultset.IOriginalDataProvider; +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.DataSetProtein; + +/** + * @author Franz-Josef Elmer + */ +public class ListDataSetProteinDataProvider implements IOriginalDataProvider<DataSetProtein> +{ + private final IPhosphoNetXServer server; + + private final String sessionToken; + + private final TechId experimentID; + + private final TechId proteinReferenceID; + + ListDataSetProteinDataProvider(IPhosphoNetXServer server, String sessionToken, + TechId experimentID, TechId proteinReferenceID) + { + this.server = server; + this.sessionToken = sessionToken; + this.experimentID = experimentID; + this.proteinReferenceID = proteinReferenceID; + } + + public List<DataSetProtein> getOriginalData() throws UserFailureException + { + return server.listProteinsByExperimentAndReference(sessionToken, experimentID, + proteinReferenceID); + } + +} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/PhosphoNetXClientService.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/PhosphoNetXClientService.java index a471a9c70ba..cb81bab75a8 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/PhosphoNetXClientService.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/PhosphoNetXClientService.java @@ -29,11 +29,13 @@ import ch.systemsx.cisd.openbis.generic.client.web.server.translator.UserFailure import ch.systemsx.cisd.openbis.generic.shared.IServer; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.IPhosphoNetXClientService; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ListProteinByExperimentAndReferenceCriteria; import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ListProteinByExperimentCriteria; import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ListProteinSequenceCriteria; import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ProteinInfo; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IPhosphoNetXServer; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.ResourceNames; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.DataSetProtein; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinByExperiment; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinSequence; @@ -105,4 +107,19 @@ public class PhosphoNetXClientService extends AbstractClientService implements return prepareExportEntities(exportCriteria); } + public ResultSet<DataSetProtein> listProteinsByExperimentAndReference( + ListProteinByExperimentAndReferenceCriteria criteria) + throws ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException + { + final String sessionToken = getSessionToken(); + return listEntities(criteria, new ListDataSetProteinDataProvider(server, sessionToken, + criteria.getExperimentID(), criteria.getProteinReferenceID())); + } + + public String prepareExportDataSetProteins(TableExportCriteria<DataSetProtein> exportCriteria) + throws ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException + { + return prepareExportEntities(exportCriteria); + } + } diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/PhosphoNetXServer.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/PhosphoNetXServer.java index 2c9241cdb80..4ad9017a45a 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/PhosphoNetXServer.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/PhosphoNetXServer.java @@ -16,13 +16,10 @@ package ch.systemsx.cisd.openbis.plugin.phosphonetx.server; -import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; -import net.lemnik.eodsql.DataSet; - import org.springframework.stereotype.Component; import ch.rinn.restrictions.Private; @@ -36,15 +33,17 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; import ch.systemsx.cisd.openbis.generic.shared.dto.Session; import ch.systemsx.cisd.openbis.plugin.phosphonetx.server.business.IBusinessObjectFactory; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.server.business.IDataSetProteinTable; import ch.systemsx.cisd.openbis.plugin.phosphonetx.server.business.IProteinReferenceTable; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.server.business.IProteinSequenceTable; import ch.systemsx.cisd.openbis.plugin.phosphonetx.server.dataaccess.IPhosphoNetXDAOFactory; import ch.systemsx.cisd.openbis.plugin.phosphonetx.server.dataaccess.IProteinQueryDAO; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IPhosphoNetXServer; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.ResourceNames; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.DataSetProtein; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinByExperiment; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinSequence; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.dto.ProteinReference; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.dto.Sequence; /** * @author Franz-Josef Elmer @@ -92,8 +91,8 @@ public class PhosphoNetXServer extends AbstractServer<IPhosphoNetXServer> implem { final Session session = getSessionManager().getSession(sessionToken); IProteinReferenceTable table = specificBOFactory.createProteinReferenceTable(session); - ExperimentPE experiment = getDAOFactory().getExperimentDAO().getByTechId(experimentId); - table.load(experiment.getPermId(), falseDiscoveryRate); + String experimentPermId = getExperimentPermIDFor(experimentId); + table.load(experimentPermId, falseDiscoveryRate); return table.getProteinReferences(); } @@ -117,35 +116,28 @@ public class PhosphoNetXServer extends AbstractServer<IPhosphoNetXServer> implem public List<ProteinSequence> listProteinSequencesByProteinReference(String sessionToken, TechId proteinReferenceID) throws UserFailureException { - IProteinQueryDAO proteinQueryDAO = specificDAOFactory.getProteinQueryDAO(); - DataSet<Sequence> sequences = - proteinQueryDAO.listProteinSequencesByProteinReference(proteinReferenceID.getId()); - ArrayList<ProteinSequence> proteinSequences = - new ArrayList<ProteinSequence>(sequences.size()); - int number = 0; - for (Sequence sequence : sequences) - { - ProteinSequence proteinSequence = new ProteinSequence(); - proteinSequence.setId(new TechId(sequence.getId())); - proteinSequence.setShortName(createShortName(number++)); - proteinSequence.setSequence(sequence.getSequence()); - proteinSequence.setDatabaseNameAndVersion(sequence.getDatabaseNameAndVersion()); - proteinSequences.add(proteinSequence); - } - sequences.close(); - return proteinSequences; + final Session session = getSessionManager().getSession(sessionToken); + IProteinSequenceTable sequenceTable = specificBOFactory.createProteinSequenceTable(session); + sequenceTable.loadByReference(proteinReferenceID); + return sequenceTable.getSequences(); } - private String createShortName(int number) + public List<DataSetProtein> listProteinsByExperimentAndReference(String sessionToken, + TechId experimentId, TechId proteinReferenceID) throws UserFailureException { - StringBuilder builder = new StringBuilder(); - int n = number; - while (n > 0) - { - builder.insert(0, "ABCEDEFGHIJKLMNOPQRSTUVWXYZ".charAt(n % 26)); - n /= 26; - } - return builder.toString(); + final Session session = getSessionManager().getSession(sessionToken); + IProteinSequenceTable sequenceTable = specificBOFactory.createProteinSequenceTable(session); + sequenceTable.loadByReference(proteinReferenceID); + IDataSetProteinTable dataSetProteinTable = specificBOFactory.createDataSetProteinTable(session); + dataSetProteinTable.load(getExperimentPermIDFor(experimentId), proteinReferenceID, sequenceTable); + return dataSetProteinTable.getDataSetProteins(); } + private String getExperimentPermIDFor(TechId experimentId) + { + ExperimentPE experiment = getDAOFactory().getExperimentDAO().getByTechId(experimentId); + String experimentPermId = experiment.getPermId(); + return experimentPermId; + } + } diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/PhosphoNetXServerLogger.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/PhosphoNetXServerLogger.java index 8f97366476e..3eb3726b782 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/PhosphoNetXServerLogger.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/PhosphoNetXServerLogger.java @@ -24,6 +24,7 @@ import ch.systemsx.cisd.openbis.generic.server.AbstractServerLogger; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.dto.Session; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IPhosphoNetXServer; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.DataSetProtein; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinByExperiment; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinSequence; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.dto.ProteinReference; @@ -63,4 +64,12 @@ public class PhosphoNetXServerLogger extends AbstractServerLogger implements IPh return null; } + public List<DataSetProtein> listProteinsByExperimentAndReference(String sessionToken, + TechId experimentId, TechId proteinReferenceID) throws UserFailureException + { + logAccess(sessionToken, "list_proteins_by_experiment_and_reference", + "EXPERIMENT_ID(%s) PROTEIN_REFERENCE_ID(%s)", experimentId, proteinReferenceID); + return null; + } + } diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/BusinessObjectFactory.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/BusinessObjectFactory.java index 7c13a6e6c2b..c2e2d5cc4c9 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/BusinessObjectFactory.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/BusinessObjectFactory.java @@ -41,4 +41,14 @@ public class BusinessObjectFactory implements IBusinessObjectFactory return new ProteinReferenceTable(daoFactory, specificDAOFactory, session); } + public IProteinSequenceTable createProteinSequenceTable(Session session) + { + return new ProteinSequenceTable(daoFactory, specificDAOFactory, session); + } + + public IDataSetProteinTable createDataSetProteinTable(Session session) + { + return new DataSetProteinTable(daoFactory, specificDAOFactory, session); + } + } diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/DataSetProteinTable.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/DataSetProteinTable.java new file mode 100644 index 00000000000..d04928a610b --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/DataSetProteinTable.java @@ -0,0 +1,76 @@ +/* + * 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.server.business; + +import java.util.ArrayList; +import java.util.List; + +import net.lemnik.eodsql.DataSet; + +import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.dto.Session; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.server.dataaccess.IPhosphoNetXDAOFactory; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.server.dataaccess.IProteinQueryDAO; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.DataSetProtein; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.dto.IdentifiedProtein; + +/** + * + * + * @author Franz-Josef Elmer + */ +class DataSetProteinTable extends AbstractBusinessObject implements IDataSetProteinTable +{ + private List<DataSetProtein> dataSetProteins; + + DataSetProteinTable(IDAOFactory daoFactory, IPhosphoNetXDAOFactory specificDAOFactory, + Session session) + { + super(daoFactory, specificDAOFactory, session); + } + + public List<DataSetProtein> getDataSetProteins() + { + return dataSetProteins; + } + + public void load(String experimentPermID, TechId proteinReferenceID, + IProteinSequenceTable sequenceTable) + { + IProteinQueryDAO proteinQueryDAO = getSpecificDAOFactory().getProteinQueryDAO(); + ErrorModel errorModel = new ErrorModel(getSpecificDAOFactory()); + DataSet<IdentifiedProtein> proteins = + proteinQueryDAO.listProteinsByProteinReferenceAndExperiment(experimentPermID, + proteinReferenceID.getId()); + dataSetProteins = new ArrayList<DataSetProtein>(); + for (IdentifiedProtein protein : proteins) + { + errorModel.setFalseDiscoveryRateFor(protein); + DataSetProtein dataSetProtein = new DataSetProtein(); + dataSetProtein.setDataSetID(new TechId(protein.getDataSetID())); + dataSetProtein.setDataSetPermID(protein.getDataSetPermID()); + dataSetProtein.setFalseDiscoveryRate(protein.getFalseDiscoveryRate()); + dataSetProtein.setPeptideCount(protein.getPeptideCount()); + dataSetProtein.setProteinID(new TechId(protein.getProteinID())); + dataSetProtein.setSequenceName(sequenceTable.getShortName(protein.getDatabaseID())); + dataSetProteins.add(dataSetProtein); + } + proteins.close(); + } + +} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/IBusinessObjectFactory.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/IBusinessObjectFactory.java index 059dc69b358..47e2d166ed8 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/IBusinessObjectFactory.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/IBusinessObjectFactory.java @@ -26,4 +26,8 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.Session; public interface IBusinessObjectFactory { public IProteinReferenceTable createProteinReferenceTable(Session session); + + public IProteinSequenceTable createProteinSequenceTable(Session session); + + public IDataSetProteinTable createDataSetProteinTable(Session session); } diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/IDataSetProteinTable.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/IDataSetProteinTable.java new file mode 100644 index 00000000000..d655b3398ac --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/IDataSetProteinTable.java @@ -0,0 +1,36 @@ +/* + * 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.server.business; + +import java.util.List; + +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.DataSetProtein; + +/** + * + * + * @author Franz-Josef Elmer + */ +public interface IDataSetProteinTable +{ + public List<DataSetProtein> getDataSetProteins(); + + public void load(String experimentPermID, TechId proteinReferenceID, + IProteinSequenceTable sequenceTable); + +} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/IProteinSequenceTable.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/IProteinSequenceTable.java new file mode 100644 index 00000000000..4ee2cfed228 --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/IProteinSequenceTable.java @@ -0,0 +1,37 @@ +/* + * 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.server.business; + +import java.util.List; + +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinSequence; + +/** + * + * + * @author Franz-Josef Elmer + */ +public interface IProteinSequenceTable +{ + + public void loadByReference(TechId proteinReferenceID); + + public List<ProteinSequence> getSequences(); + + public String getShortName(long databaseID); +} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/ProteinSequenceTable.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/ProteinSequenceTable.java new file mode 100644 index 00000000000..ffd31325cb7 --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/business/ProteinSequenceTable.java @@ -0,0 +1,109 @@ +/* + * 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.server.business; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.lemnik.eodsql.DataSet; + +import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.dto.Session; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.server.dataaccess.IPhosphoNetXDAOFactory; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.server.dataaccess.IProteinQueryDAO; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinSequence; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.dto.Sequence; + +/** + * + * + * @author Franz-Josef Elmer + */ +class ProteinSequenceTable extends AbstractBusinessObject implements IProteinSequenceTable +{ + private List<ProteinSequence> proteinSequences; + private Map<Long, String> databaseIDToShortNameMap; + + ProteinSequenceTable(IDAOFactory daoFactory, IPhosphoNetXDAOFactory specificDAOFactory, + Session session) + { + super(daoFactory, specificDAOFactory, session); + } + + public List<ProteinSequence> getSequences() + { + if (proteinSequences == null) + { + throw new IllegalStateException("Sequences not loaded."); + } + return proteinSequences; + } + + public String getShortName(long databaseID) + { + if (databaseIDToShortNameMap == null) + { + throw new IllegalStateException("Sequences not loaded."); + } + String shortName = databaseIDToShortNameMap.get(databaseID); + if (shortName == null) + { + throw new IllegalArgumentException("No sequence found for databaseID " + databaseID); + } + return shortName; + } + + public void loadByReference(TechId proteinReferenceID) + { + IProteinQueryDAO proteinQueryDAO = getSpecificDAOFactory().getProteinQueryDAO(); + DataSet<Sequence> sequences = + proteinQueryDAO.listProteinSequencesByProteinReference(proteinReferenceID.getId()); + proteinSequences = new ArrayList<ProteinSequence>(sequences.size()); + databaseIDToShortNameMap = new HashMap<Long, String>(); + int number = 0; + for (Sequence sequence : sequences) + { + ProteinSequence proteinSequence = new ProteinSequence(); + proteinSequence.setId(new TechId(sequence.getId())); + String shortName = createShortName(number++); + proteinSequence.setShortName(shortName); + proteinSequence.setSequence(sequence.getSequence()); + long databaseID = sequence.getDatabaseID(); + proteinSequence.setDatabaseID(new TechId(databaseID)); + proteinSequence.setDatabaseNameAndVersion(sequence.getDatabaseNameAndVersion()); + proteinSequences.add(proteinSequence); + databaseIDToShortNameMap.put(databaseID, shortName); + } + sequences.close(); + } + + private String createShortName(int number) + { + StringBuilder builder = new StringBuilder(); + int n = number; + while (n > 0 || builder.length() == 0) + { + builder.insert(0, "ABCEDEFGHIJKLMNOPQRSTUVWXYZ".charAt(n % 26)); + n /= 26; + } + return builder.toString(); + } + +} 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 a0df8f0b13f..1f57e069096 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 @@ -47,21 +47,22 @@ public interface IProteinQueryDAO extends BaseQuery @Select("select * from protein_references where id = ?{1}") public ProteinReference tryToGetProteinReference(long proteinReferenceID); - @Select("select s.id, amino_acid_sequence, name_and_version " + @Select("select s.id, db_id, amino_acid_sequence, name_and_version " + "from sequences as s join databases as d on s.db_id = d.id " + "where s.prre_id = ?{1} order by name_and_version") public DataSet<Sequence> listProteinSequencesByProteinReference(long proteinReferenceID); @Select("select ds.id as data_set_id, ds.perm_id as data_set_perm_id, p.id as protein_id, " - + "probability, count(pe.id) as peptide_count, amino_acid_sequence, name_and_version " - + "from data_sets as ds join proteins as p on p.dase_id = ds.id " + + "probability, count(pe.id) as peptide_count, amino_acid_sequence, s.db_id " + + "from data_sets as ds join experiments as e on ds.expe_id = e.id " + + " join proteins as p on p.dase_id = ds.id " + " join identified_proteins as i on i.prot_id = p.id " + " join sequences as s on i.sequ_id = s.id " + " join databases as db on s.db_id = db.id " + " left join peptides as pe on pe.prot_id = p.id " - + "where s.prre_id = ?{2} and ds.expe_id = ?{1} " + + "where s.prre_id = ?{2} and e.perm_id = ?{1} " + "group by data_set_id, data_set_perm_id, protein_id, probability, " - + " amino_acid_sequence, name_and_version order by data_set_perm_id") + + " amino_acid_sequence, s.db_id order by data_set_perm_id") public DataSet<IdentifiedProtein> listProteinsByProteinReferenceAndExperiment( - long experimentID, long proteinReferenceID); + String experimentPermID, long proteinReferenceID); } diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/IPhosphoNetXServer.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/IPhosphoNetXServer.java index 61b936b02f1..95e8184589d 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/IPhosphoNetXServer.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/IPhosphoNetXServer.java @@ -27,6 +27,7 @@ import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RoleSet; import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RolesAllowed; import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.AbstractTechIdPredicate.ExperimentTechIdPredicate; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.DataSetProtein; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinByExperiment; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.ProteinSequence; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.dto.ProteinReference; @@ -54,4 +55,11 @@ public interface IPhosphoNetXServer extends IServer @RolesAllowed(RoleSet.OBSERVER) public List<ProteinSequence> listProteinSequencesByProteinReference(String sessionToken, TechId proteinReferenceID) throws UserFailureException; + + @Transactional + @RolesAllowed(RoleSet.OBSERVER) + public List<DataSetProtein> listProteinsByExperimentAndReference(String sessionToken, + @AuthorizationGuard(guardClass = ExperimentTechIdPredicate.class) + TechId experimentId, TechId proteinReferenceID) throws UserFailureException; + } diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/basic/dto/DataSetProtein.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/basic/dto/DataSetProtein.java new file mode 100644 index 00000000000..79ac33495e1 --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/basic/dto/DataSetProtein.java @@ -0,0 +1,107 @@ +/* + * 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.shared.basic.dto; + +import java.io.Serializable; + +import com.google.gwt.user.client.rpc.IsSerializable; + +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ServiceVersionHolder; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class DataSetProtein implements IsSerializable, Serializable +{ + private static final long serialVersionUID = ServiceVersionHolder.VERSION; + + private String dataSetPermID; + + private TechId dataSetID; + + private TechId proteinID; + + private String sequenceName; + + private int peptideCount; + + private double falseDiscoveryRate; + + public final String getDataSetPermID() + { + return dataSetPermID; + } + + public final void setDataSetPermID(String dataSetPermID) + { + this.dataSetPermID = dataSetPermID; + } + + public final TechId getDataSetID() + { + return dataSetID; + } + + public final void setDataSetID(TechId dataSetID) + { + this.dataSetID = dataSetID; + } + + public final TechId getProteinID() + { + return proteinID; + } + + public final void setProteinID(TechId proteinID) + { + this.proteinID = proteinID; + } + + public final String getSequenceName() + { + return sequenceName; + } + + public final void setSequenceName(String sequenceName) + { + this.sequenceName = sequenceName; + } + + public final int getPeptideCount() + { + return peptideCount; + } + + public final void setPeptideCount(int peptideCount) + { + this.peptideCount = peptideCount; + } + + public final double getFalseDiscoveryRate() + { + return falseDiscoveryRate; + } + + public final void setFalseDiscoveryRate(double falseDiscoveryRate) + { + this.falseDiscoveryRate = falseDiscoveryRate; + } + +} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/basic/dto/ProteinByExperiment.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/basic/dto/ProteinByExperiment.java index 3d9ee897f48..b83d457d22c 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/basic/dto/ProteinByExperiment.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/basic/dto/ProteinByExperiment.java @@ -17,8 +17,6 @@ package ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto; import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; import com.google.gwt.user.client.rpc.IsSerializable; @@ -38,8 +36,6 @@ public class ProteinByExperiment implements IsSerializable, Serializable private String description; - private List<ProteinSequence> sequences = new ArrayList<ProteinSequence>(); - public final String getUniprotID() { return uniprotID; @@ -60,15 +56,4 @@ public class ProteinByExperiment implements IsSerializable, Serializable this.description = description; } - public final List<ProteinSequence> getSequences() - { - return sequences; - } - - public final void addSequence(ProteinSequence proteinSequence) - { - this.sequences.add(proteinSequence); - } - - } diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/basic/dto/ProteinSequence.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/basic/dto/ProteinSequence.java index e8a00621c49..188adbd03d7 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/basic/dto/ProteinSequence.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/basic/dto/ProteinSequence.java @@ -36,6 +36,8 @@ public class ProteinSequence implements IsSerializable, Serializable private TechId id; + private TechId databaseID; + private String sequence; private String databaseNameAndVersion; @@ -60,6 +62,16 @@ public class ProteinSequence implements IsSerializable, Serializable this.id = id; } + public final TechId getDatabaseID() + { + return databaseID; + } + + public final void setDatabaseID(TechId databaseID) + { + this.databaseID = databaseID; + } + public final String getSequence() { return sequence; diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/dto/IdentifiedProtein.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/dto/IdentifiedProtein.java index 7f78dcd9148..52b08cecea8 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/dto/IdentifiedProtein.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/dto/IdentifiedProtein.java @@ -40,8 +40,8 @@ public class IdentifiedProtein extends AbstractDTOWithID @ResultColumn("amino_acid_sequence") private String sequence; - @ResultColumn("name_and_version") - private String database; + @ResultColumn("db_id") + private long databaseID; @ResultColumn("probability") private double probability; @@ -118,14 +118,14 @@ public class IdentifiedProtein extends AbstractDTOWithID this.falseDiscoveryRate = falseDiscoveryRate; } - public final String getDatabase() + public final long getDatabaseID() { - return database; + return databaseID; } - public final void setDatabase(String database) + public final void setDatabase(long databaseID) { - this.database = database; + this.databaseID = databaseID; } diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/dto/Sequence.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/dto/Sequence.java index 10fa8f96222..f05316ea8bd 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/dto/Sequence.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/dto/Sequence.java @@ -29,6 +29,9 @@ public class Sequence extends AbstractDTOWithID @ResultColumn("amino_acid_sequence") private String sequence; + @ResultColumn("db_id") + private long databaseID; + @ResultColumn("name_and_version") private String databaseNameAndVersion; @@ -42,6 +45,16 @@ public class Sequence extends AbstractDTOWithID this.sequence = sequence; } + public final long getDatabaseID() + { + return databaseID; + } + + public final void setDatabaseID(long databaseID) + { + this.databaseID = databaseID; + } + public final String getDatabaseNameAndVersion() { return databaseNameAndVersion; -- GitLab