From 6da1b74265ff65919ea4cd7211d53c014773fa57 Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Wed, 12 Jan 2011 12:52:35 +0000 Subject: [PATCH] LMS-1957 rename ProteinTableReport to APMSReport. Columns 'num unique peptides' and 'spec count' in agreement with Lars. APMSReportTest written. SVN: 19389 --- rtd_phosphonetx/etc/service.properties | 12 +- ...roteinTableReport.java => APMSReport.java} | 56 ++-- .../server/plugins/APMSReportTest.java | 289 ++++++++++++++++++ .../plugins/ProteinTableReportTest.java | 74 ----- 4 files changed, 333 insertions(+), 98 deletions(-) rename rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/dss/phosphonetx/server/plugins/{ProteinTableReport.java => APMSReport.java} (89%) create mode 100644 rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/dss/phosphonetx/server/plugins/APMSReportTest.java delete mode 100644 rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/dss/phosphonetx/server/plugins/ProteinTableReportTest.java diff --git a/rtd_phosphonetx/etc/service.properties b/rtd_phosphonetx/etc/service.properties index c7349c5bf02..447eb4f760c 100644 --- a/rtd_phosphonetx/etc/service.properties +++ b/rtd_phosphonetx/etc/service.properties @@ -109,7 +109,7 @@ data-set-file-name-entity-separator = _ # Note that this can increase the server load. # reprocess-faulty-datasets = false -reporting-plugins = demo-reporter +reporting-plugins = demo-reporter, protein-table-report # Label of the plugin which will be shown for the users. demo-reporter.label = Show Dataset Size @@ -120,8 +120,12 @@ demo-reporter.class = ch.systemsx.cisd.openbis.dss.generic.server.plugins.demo.D # The property file. Its content will be passed as a parameter to the plugin. demo-reporter.properties-file = +protein-table-report.label = APMS Report +protein-table-report.class = ch.systemsx.cisd.openbis.dss.phosphonetx.server.plugins.APMSReport +protein-table-report.dataset-types = PROT_RESULT + # Comma separated names of processing plugins. Each plugin should have configuration properties prefixed with its name. -processing-plugins = copy-data-sets, ms-inj-copy +processing-plugins = copy-data-sets, ms-inj-copy, protein-table-report-creation # The configuration of the processing plugin is the same as the reporting plugins configuration. copy-data-sets.label = Data Set Copier to User Location @@ -139,6 +143,10 @@ ms-inj-copy.send-detailed-email = true #ms-inj-copy.destination = /Volumes/share-1-\$/user/cisd/felmer/phosphonetx/ ms-inj-copy.destination = vesuvio:tmp +protein-table-report-creation.label = Send me the APMS Report +protein-table-report-creation.class = ch.systemsx.cisd.openbis.dss.phosphonetx.server.plugins.APMSReport +protein-table-report-creation.dataset-types = PROT_RESULT + data-set-validators = val1 val1.data-set-type = HCS_IMAGE_ANALYSIS_DATA diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/dss/phosphonetx/server/plugins/ProteinTableReport.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/dss/phosphonetx/server/plugins/APMSReport.java similarity index 89% rename from rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/dss/phosphonetx/server/plugins/ProteinTableReport.java rename to rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/dss/phosphonetx/server/plugins/APMSReport.java index 724bfdc6246..ed24ec4c88d 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/dss/phosphonetx/server/plugins/ProteinTableReport.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/dss/phosphonetx/server/plugins/APMSReport.java @@ -48,6 +48,7 @@ import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; import ch.systemsx.cisd.common.mail.EMailAddress; +import ch.systemsx.cisd.common.utilities.Template; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard.AbstractTableModelReportingPlugin; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.IProcessingPluginTask; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ProcessingStatus; @@ -59,7 +60,6 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DoubleTableCell; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ISerializableComparable; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IntegerTableCell; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListSampleCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Material; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; @@ -72,11 +72,11 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifierFactory; /** - * Creates a report from proteins.csv + * Creates an APMS report from proteins.csv * * @author Franz-Josef Elmer */ -public class ProteinTableReport extends AbstractTableModelReportingPlugin implements IProcessingPluginTask +public class APMSReport extends AbstractTableModelReportingPlugin implements IProcessingPluginTask { private static final class Header { @@ -189,16 +189,21 @@ public class ProteinTableReport extends AbstractTableModelReportingPlugin implem @Private static final String PROTEIN_FILE_NAME = "proteins.csv"; private static final String PROTEIN_PROPERTY_CODE_KEY = "protein-property-code"; - private static final String DEFAULT_PROTEIN_PROPERTY_CODE = "PROTEIN"; + @Private static final String DEFAULT_PROTEIN_PROPERTY_CODE = "PROTEIN"; + + private + static final Template E_MAIL_CONTENT_TEMPLATE = new Template("Dear User\n\n" + + "Enclosed you will find the Protein APMS report file for experiment ${experiment-identifier}.\n" + + "Data Set: ${data-set}"); private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, - ProteinTableReport.class); + APMSReport.class); private final String proteinPropertyCode; private IEncapsulatedOpenBISService service; - public ProteinTableReport(Properties properties, File storeRoot) + public APMSReport(Properties properties, File storeRoot) { super(properties, storeRoot); proteinPropertyCode = properties.getProperty(PROTEIN_PROPERTY_CODE_KEY, DEFAULT_PROTEIN_PROPERTY_CODE); @@ -258,11 +263,17 @@ public class ProteinTableReport extends AbstractTableModelReportingPlugin implem } csvWriter.writeRecord(stringArray); } + String experimentIdentifier = + datasetDescription.getSpaceCode() + '/' + datasetDescription.getProjectCode() + + '/' + datasetDescription.getExperimentCode(); + Template template = E_MAIL_CONTENT_TEMPLATE.createFreshCopy(); + template.bind("experiment-identifier", experimentIdentifier); + template.bind("data-set", datasetDescription.getDatasetCode()); ByteArrayDataSource dataSource = new ByteArrayDataSource(writer.toString(), "text/plain"); context.getMailClient().sendEmailMessageWithAttachment("Protein APMS Report", - "Here is your report", - datasetDescription.getExperimentCode() + "-protein-report.txt", + template.createText(), + datasetDescription.getExperimentCode() + "-APMS-report.txt", new DataHandler(dataSource), null, null, new EMailAddress(context.getUserEmailOrNull())); @@ -281,8 +292,6 @@ public class ProteinTableReport extends AbstractTableModelReportingPlugin implem builder.addHeader("Sample ID"); builder.addHeader("Bait"); builder.addHeader("Prey"); - builder.addHeader("num unique peptides"); - builder.addHeader("spec count"); builder.addHeader("freq of obs"); builder.addHeader("avg MS1 intensities (normalized for the bait)"); builder.addHeader("STDV MS1 intensity"); @@ -340,12 +349,12 @@ public class ProteinTableReport extends AbstractTableModelReportingPlugin implem for (Entry<String, List<Header>> group : groups) { String biologicalSample = group.getKey(); - List<Header> hs = group.getValue(); + List<Header> headers = group.getValue(); String protein = null; double countNonZeroAbundances = 0; double sum = 0; double sum2 = 0; - for (Header header : hs) + for (Header header : headers) { if (biologicalSample != null && protein == null) { @@ -367,17 +376,20 @@ public class ProteinTableReport extends AbstractTableModelReportingPlugin implem + value + ") for column " + header.getHeader() + ": " + row); } } - double averagedAbundance = sum / hs.size(); + double averagedAbundance = sum / headers.size(); double abundanceStandardDeviation = - Math.sqrt(averagedAbundance * averagedAbundance - sum2 / hs.size()); - double frequencyOfObservation = countNonZeroAbundances / hs.size(); - builder.addRow(Arrays.<ISerializableComparable> asList(new StringTableCell( - biologicalSample), new StringTableCell(protein), new StringTableCell( - identifiedProtein), - new IntegerTableCell(Long.parseLong(row.getValue("n_peptides"))), - new StringTableCell(""), new DoubleTableCell(frequencyOfObservation), - new DoubleTableCell(averagedAbundance), new DoubleTableCell( - abundanceStandardDeviation))); + Math.sqrt(Math.max(0, sum2 / headers.size() - averagedAbundance + * averagedAbundance)); + double frequencyOfObservation = countNonZeroAbundances / headers.size(); + StringTableCell biologicalSampleCell = StringTableCell.wrap(biologicalSample); + StringTableCell proteinCell = StringTableCell.wrap(protein); + StringTableCell identifiedProteinCell = new StringTableCell(identifiedProtein); + DoubleTableCell freqOfObsvCell = new DoubleTableCell(frequencyOfObservation); + DoubleTableCell abundanceCell = new DoubleTableCell(averagedAbundance); + DoubleTableCell abundanceStdvCell = new DoubleTableCell(abundanceStandardDeviation); + builder.addRow(Arrays.<ISerializableComparable> asList(biologicalSampleCell, + proteinCell, identifiedProteinCell, freqOfObsvCell, abundanceCell, + abundanceStdvCell)); } } diff --git a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/dss/phosphonetx/server/plugins/APMSReportTest.java b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/dss/phosphonetx/server/plugins/APMSReportTest.java new file mode 100644 index 00000000000..b13269dffca --- /dev/null +++ b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/dss/phosphonetx/server/plugins/APMSReportTest.java @@ -0,0 +1,289 @@ +/* + * Copyright 2011 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.dss.phosphonetx.server.plugins; + +import static ch.systemsx.cisd.openbis.dss.phosphonetx.server.plugins.APMSReport.DEFAULT_PROTEIN_PROPERTY_CODE; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Properties; +import java.util.Set; + +import javax.activation.DataHandler; + +import org.apache.commons.io.IOUtils; +import org.hamcrest.BaseMatcher; +import org.hamcrest.Description; +import org.hamcrest.core.IsNull; +import org.jmock.Expectations; +import org.jmock.Mockery; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import ch.rinn.restrictions.Friend; +import ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase; +import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.common.filesystem.FileUtilities; +import ch.systemsx.cisd.common.mail.EMailAddress; +import ch.systemsx.cisd.common.mail.IMailClient; +import ch.systemsx.cisd.common.test.RecordingMatcher; +import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.ProcessingStatus; +import ch.systemsx.cisd.openbis.dss.generic.shared.DataSetProcessingContext; +import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListSampleCriteria; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModel; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelColumnHeader; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRow; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.builders.SampleBuilder; +import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; +import ch.systemsx.cisd.openbis.generic.shared.dto.builders.DatasetDescriptionBuilder; +import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifierFactory; + +/** + * @author Franz-Josef Elmer + */ +@Friend(toClasses = APMSReport.class) +public class APMSReportTest extends AbstractFileSystemTestCase +{ + private static final String EXAMPLE_PROTEINS = + "# Protein abundances computed from file 'result.consensusXML'\n" + + "# Parameters (relevant only): top=3, average=median, include_all, consensus:normalize\n" + + "# Files/samples associated with abundance values below:" + + " 0: '/cluster/s1.featureXML'," + + " 1: '/cluster/s2.featureXML'," + + " 2: '/cluster/s3.featureXML'\n" + + "\"protein\",\"n_proteins\",\"protein_score\",\"n_peptides\",\"abundance_0\",\"abundance_1\",\"abundance_2\"\n" + + "\"P1\",1,1,5,1.5,2.5,3.5\n" + + "\"P2\",1,1,6,11.5,0,13.5\n" + + "\"P3\",1,1,14,21.5,22.5,0\n"; + + private Mockery context; + + private APMSReport report; + + private IEncapsulatedOpenBISService service; + + private IMailClient mailClient; + + @BeforeMethod + public void beforeMethod() + { + File dataSetFolder = createDataSet("1"); + FileUtilities.writeToFile(new File(dataSetFolder, APMSReport.PROTEIN_FILE_NAME), + EXAMPLE_PROTEINS); + createDataSet("2"); + + context = new Mockery(); + service = context.mock(IEncapsulatedOpenBISService.class); + mailClient = context.mock(IMailClient.class); + report = new APMSReport(new Properties(), workingDirectory); + report.setService(service); + } + + private File createDataSet(String location) + { + File originalFolder = new File(new File(workingDirectory, location), "original"); + originalFolder.mkdirs(); + File dataSetFolder = new File(originalFolder, "data-set-folder"); + dataSetFolder.mkdirs(); + return dataSetFolder; + } + + @AfterMethod + public void afterMethod() + { + // To following line of code should also be called at the end of each test method. + // Otherwise one do not known which test failed. + context.assertIsSatisfied(); + } + + @Test + public void testProcess() throws IOException + { + Sample b2 = new SampleBuilder("/S/B2").id(12).getSample(); + prepareGetSample(new SampleBuilder("/MS_DATA/S1").id(1).childOf(b2).getSample()); + prepareGetSample(new SampleBuilder("/MS_DATA/S2").id(2).childOf(b2).getSample()); + prepareGetSample(new SampleBuilder("/MS_DATA/S3").id(3).childOf(b2).getSample()); + DatasetDescriptionBuilder ds1 = + new DatasetDescriptionBuilder("ds1").location("1").space("s").project("p") + .experiment("e"); + DatasetDescriptionBuilder ds2 = new DatasetDescriptionBuilder("ds2").location("2"); + List<DatasetDescription> dataSets = + Arrays.asList(ds1.getDatasetDescription(), ds2.getDatasetDescription()); + DataSetProcessingContext processingContext = + new DataSetProcessingContext(Collections.<String, String> emptyMap(), mailClient, + "a@bc.de"); + final RecordingMatcher<String> subjectMatcher = new RecordingMatcher<String>(); + final RecordingMatcher<String> contentMatcher = new RecordingMatcher<String>(); + final RecordingMatcher<String> fileNameMatcher = new RecordingMatcher<String>(); + final RecordingMatcher<DataHandler> attachmentMatcher = new RecordingMatcher<DataHandler>(); + final RecordingMatcher<EMailAddress[]> addressesMatcher = + new RecordingMatcher<EMailAddress[]>(); + context.checking(new Expectations() + { + { + one(mailClient).sendEmailMessageWithAttachment(with(subjectMatcher), + with(contentMatcher), with(fileNameMatcher), with(attachmentMatcher), + with(new IsNull<EMailAddress>()), with(new IsNull<EMailAddress>()), + with(addressesMatcher)); + } + }); + + ProcessingStatus status = report.process(dataSets, processingContext); + assertEquals("Protein APMS Report", subjectMatcher.recordedObject()); + assertEquals("Dear User\n\n" + + "Enclosed you will find the Protein APMS report file for experiment s/p/e.\n" + + "Data Set: ds1", contentMatcher.recordedObject()); + @SuppressWarnings("unchecked") + List<String> fileLines = + IOUtils.readLines(attachmentMatcher.recordedObject().getInputStream()); + assertEquals("Sample ID,Bait,Prey,freq of obs," + + "avg MS1 intensities (normalized for the bait),STDV MS1 intensity", + fileLines.get(0)); + assertEquals(4, fileLines.size()); + assertEquals("[ERROR: \"Exception occured: " + + "ch.systemsx.cisd.common.exceptions.UserFailureException: File " + + APMSReport.PROTEIN_FILE_NAME + " missing.\"]", status.getErrorStatuses() + .toString()); + + context.assertIsSatisfied(); + } + + @Test + public void testCreateReport() + { + Sample master = + new SampleBuilder("/master").property(DEFAULT_PROTEIN_PROPERTY_CODE, "Q1") + .getSample(); + Sample b1 = new SampleBuilder("/S/B1").id(11).childOf(master).getSample(); + Sample b2 = new SampleBuilder("/S/B2").id(12).getSample(); + prepareGetSample(new SampleBuilder("/MS_DATA/S1").id(1).childOf(b1).getSample()); + prepareGetSample(new SampleBuilder("/MS_DATA/S2").id(2).childOf(b1).getSample()); + prepareGetSample(new SampleBuilder("/MS_DATA/S3").id(3).childOf(b2).getSample()); + DatasetDescriptionBuilder ds1 = new DatasetDescriptionBuilder("ds1").location("1"); + List<DatasetDescription> dataSets = Arrays.asList(ds1.getDatasetDescription()); + + TableModel table = report.createReport(dataSets); + + List<TableModelColumnHeader> headers = table.getHeader(); + assertEquals("[Sample ID, Bait, Prey, freq of obs, " + + "avg MS1 intensities (normalized for the bait), STDV MS1 intensity]", + headers.toString()); + List<TableModelRow> rows = table.getRows(); + assertEquals("[B1, Q1, P1, 1.0, 2.0, 0.5]", rows.get(0).getValues().toString()); + assertEquals("[B2, , P1, 1.0, 3.5, 0.0]", rows.get(1).getValues().toString()); + assertEquals("[B1, Q1, P2, 0.5, 5.75, 5.75]", rows.get(2).getValues().toString()); + assertEquals("[B2, , P2, 1.0, 13.5, 0.0]", rows.get(3).getValues().toString()); + assertEquals("[B1, Q1, P3, 1.0, 22.0, 0.5]", rows.get(4).getValues().toString()); + assertEquals("[B2, , P3, 0.0, 0.0, 0.0]", rows.get(5).getValues().toString()); + assertEquals(3 * 2, rows.size()); + + context.assertIsSatisfied(); + } + + @Test + public void testCreateReportForMissingProteinsFile() + { + DatasetDescriptionBuilder ds = new DatasetDescriptionBuilder("ds2").location("2"); + try + { + report.createReport(Arrays.asList(ds.getDatasetDescription())); + fail("UserFailureException expected"); + } catch (UserFailureException ex) + { + assertEquals("File " + APMSReport.PROTEIN_FILE_NAME + " missing.", ex.getMessage()); + } + + context.assertIsSatisfied(); + } + + @Test + public void testCreateReportForTwoDataSets() + { + DatasetDescriptionBuilder ds1 = new DatasetDescriptionBuilder("ds1").location("1"); + DatasetDescriptionBuilder ds2 = new DatasetDescriptionBuilder("ds2").location("2"); + try + { + report.createReport(Arrays.asList(ds1.getDatasetDescription(), + ds2.getDatasetDescription())); + fail("UserFailureException expected"); + } catch (UserFailureException ex) + { + assertEquals("Chosen plugin works with exactly one data set. 2 data sets selected.", + ex.getMessage()); + } + + context.assertIsSatisfied(); + } + + private void prepareGetSample(final Sample sample) + { + context.checking(new Expectations() + { + { + one(service).tryGetSampleWithExperiment( + SampleIdentifierFactory.parse(sample.getIdentifier())); + will(returnValue(sample)); + } + }); + prepareGetAncestors(sample); + } + + protected void prepareGetAncestors(final Sample sample) + { + List<IEntityProperty> properties = sample.getProperties(); + for (IEntityProperty property : properties) + { + if (property.getPropertyType().getCode().equals(DEFAULT_PROTEIN_PROPERTY_CODE)) + { + return; + } + } + final Set<Sample> parents = sample.getParents(); + context.checking(new Expectations() + { + { + one(service).listSamples(with(new BaseMatcher<ListSampleCriteria>() + { + public boolean matches(Object item) + { + return sample.getId() == ((ListSampleCriteria) item) + .getChildSampleId().getId(); + } + + public void describeTo(Description description) + { + description.appendText("parents of " + sample.getIdentifier()); + } + })); + will(returnValue(new ArrayList<Sample>(parents))); + } + }); + for (Sample parent : parents) + { + prepareGetAncestors(parent); + } + } + +} diff --git a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/dss/phosphonetx/server/plugins/ProteinTableReportTest.java b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/dss/phosphonetx/server/plugins/ProteinTableReportTest.java deleted file mode 100644 index b35c6727b27..00000000000 --- a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/dss/phosphonetx/server/plugins/ProteinTableReportTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2011 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.dss.phosphonetx.server.plugins; - -import java.io.File; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Properties; - -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import ch.rinn.restrictions.Friend; -import ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase; -import ch.systemsx.cisd.common.filesystem.FileUtilities; -import ch.systemsx.cisd.openbis.dss.generic.shared.DataSetProcessingContext; -import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; -import ch.systemsx.cisd.openbis.generic.shared.dto.builders.DatasetDescriptionBuilder; - - -/** - * - * - * @author Franz-Josef Elmer - */ -@Friend(toClasses=ProteinTableReport.class) -public class ProteinTableReportTest extends AbstractFileSystemTestCase -{ - private static final String EXAMPLE_PROTEINS = - "# Protein abundances computed from file 'result.consensusXML'\n" - + "# Parameters (relevant only): top=3, average=median, include_all, consensus:normalize\n" - + "# Files/samples associated with abundance values below:" - + " 0: '/cluster/weisserh_B1012_053.featureXML'," - + " 1: '/cluster/weisserh_B1012_057.featureXML'\n" - + "\"protein\",\"n_proteins\",\"protein_score\",\"n_peptides\",\"abundance_0\",\"abundance_1\"\n" - + "\"13621327\",1,1,5,7846763.86498425,8159570.13467505\n" - + "\"13621329\",1,1,6,2976845.93289974,3670078.89677526\n" - + "\"13621337\",1,1,14,18114384.6420854,14119249.6148974\n"; - - @BeforeMethod - public void beforeMethod() - { - File originalFolder = new File(new File(workingDirectory, "1"), "original"); - originalFolder.mkdirs(); - File dataSetFolder = new File(originalFolder, "data-set-folder"); - dataSetFolder.mkdirs(); - FileUtilities.writeToFile(new File(dataSetFolder, ProteinTableReport.PROTEIN_FILE_NAME), EXAMPLE_PROTEINS); - } - - @Test - public void test() - { - ProteinTableReport report = new ProteinTableReport(new Properties(), workingDirectory); - DataSetProcessingContext context = new DataSetProcessingContext(Collections.<String, String>emptyMap(), null, "a@bc.de"); - DatasetDescriptionBuilder ds1 = new DatasetDescriptionBuilder("ds1").location("1"); - List<DatasetDescription> dataSets = Arrays.asList(ds1.getDatasetDescription()); - report.process(dataSets, context); - } -} -- GitLab