From fcc28ee865ca9b7074027ea914e5e88f3aff386f Mon Sep 17 00:00:00 2001 From: jakubs <jakubs> Date: Fri, 5 Oct 2012 13:47:59 +0000 Subject: [PATCH] SP-299 BIS-211 add simple feature vectors test SVN: 27065 --- .../FeatureVectorsDropboxTest/features.csv | 97 +++++++++++++ .../feature-vector-data-set-handler.py | 65 +++++++++ .../plugin.properties | 8 ++ .../FeatureVectorsDropboxTest.java | 129 ++++++++++++++++++ 4 files changed, 299 insertions(+) create mode 100644 screening/resource/test-data/FeatureVectorsDropboxTest/features.csv create mode 100644 screening/sourceTest/core-plugins/FeatureVectorsDropboxTest/1/dss/drop-boxes/FeatureVectorsDropboxTest-drop-box/feature-vector-data-set-handler.py create mode 100644 screening/sourceTest/core-plugins/FeatureVectorsDropboxTest/1/dss/drop-boxes/FeatureVectorsDropboxTest-drop-box/plugin.properties create mode 100644 screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/FeatureVectorsDropboxTest.java diff --git a/screening/resource/test-data/FeatureVectorsDropboxTest/features.csv b/screening/resource/test-data/FeatureVectorsDropboxTest/features.csv new file mode 100644 index 00000000000..c82d36b5b69 --- /dev/null +++ b/screening/resource/test-data/FeatureVectorsDropboxTest/features.csv @@ -0,0 +1,97 @@ +barcode,Well,row number,column number,TPU,STATE +PLATE-1,A1,1,1,0.0109905507275,UNSTABLE +PLATE-1,A2,1,2,-0.0182003436984,UNSTABLE +PLATE-1,A3,1,3,-0.00805361743168,STABLE +PLATE-1,A4,1,4,0.0810000328417,STABLE +PLATE-1,A5,1,5,0.0259230435927,STABLE +PLATE-1,A6,1,6,-0.036430571554,UNSTABLE +PLATE-1,A7,1,7,-0.0101872401882,UNSTABLE +PLATE-1,A8,1,8,-0.00727317718048,STABLE +PLATE-1,A9,1,9,0.0315700979161,STABLE +PLATE-1,A10,1,10,0.168559091956,STABLE +PLATE-1,A11,1,11,-0.0250794227724,STABLE +PLATE-1,A12,1,12,0.257636061574,STABLE +PLATE-1,B1,2,1,0.100434155899,STABLE +PLATE-1,B2,2,2,0.0976115450765,UNSTABLE +PLATE-1,B3,2,3,0.0864925097496,UNSTABLE +PLATE-1,B4,2,4,0.0878168382557,STABLE +PLATE-1,B5,2,5,0.00728303315339,STABLE +PLATE-1,B6,2,6,0.00135844915617,UNSTABLE +PLATE-1,B7,2,7,0.071667990849,UNSTABLE +PLATE-1,B8,2,8,0.134576738033,STABLE +PLATE-1,B9,2,9,0.062517688301,STABLE +PLATE-1,B10,2,10,-0.0559872246124,STABLE +PLATE-1,B11,2,11,-0.0619564845848,STABLE +PLATE-1,B12,2,12,0.0324420596004,UNSTABLE +PLATE-1,C1,3,1,0.206954055141,UNSTABLE +PLATE-1,C2,3,2,0.19680434536,UNSTABLE +PLATE-1,C3,3,3,0.229279401419,UNSTABLE +PLATE-1,C4,3,4,0.193351284437,STABLE +PLATE-1,C5,3,5,0.129062893555,STABLE +PLATE-1,C6,3,6,0.126673623384,STABLE +PLATE-1,C7,3,7,0.229037975734,STABLE +PLATE-1,C8,3,8,0.223431359979,STABLE +PLATE-1,C9,3,9,0.190028172309,STABLE +PLATE-1,C10,3,10,-0.0674441033456,UNSTABLE +PLATE-1,C11,3,11,0.0339637772352,STABLE +PLATE-1,C12,3,12,0.164178194792,STABLE +PLATE-1,D1,4,1,0.297974218656,UNSTABLE +PLATE-1,D2,4,2,0.298059135512,STABLE +PLATE-1,D3,4,3,0.350772745466,UNSTABLE +PLATE-1,D4,4,4,0.313919901769,UNSTABLE +PLATE-1,D5,4,5,0.252290578613,STABLE +PLATE-1,D6,4,6,0.324830425263,UNSTABLE +PLATE-1,D7,4,7,0.162928227992,STABLE +PLATE-1,D8,4,8,0.265496427715,UNSTABLE +PLATE-1,D9,4,9,0.123242462625,STABLE +PLATE-1,D10,4,10,0.0156365936527,STABLE +PLATE-1,D11,4,11,0.318001502397,STABLE +PLATE-1,D12,4,12,0.20854731993,STABLE +PLATE-1,E1,5,1,0.393536251276,UNSTABLE +PLATE-1,E2,5,2,0.399605077357,STABLE +PLATE-1,E3,5,3,0.433901537831,STABLE +PLATE-1,E4,5,4,0.378871120619,UNSTABLE +PLATE-1,E5,5,5,0.453098222167,STABLE +PLATE-1,E6,5,6,0.308155666544,UNSTABLE +PLATE-1,E7,5,7,0.45538138854,STABLE +PLATE-1,E8,5,8,0.372161727461,STABLE +PLATE-1,E9,5,9,0.308752403413,STABLE +PLATE-1,E10,5,10,0.357322858215,UNSTABLE +PLATE-1,E11,5,11,0.408261827863,UNSTABLE +PLATE-1,E12,5,12,0.276512650311,UNSTABLE +PLATE-1,F1,6,1,0.518565455665,UNSTABLE +PLATE-1,F2,6,2,0.501353504253,UNSTABLE +PLATE-1,F3,6,3,0.486441514218,UNSTABLE +PLATE-1,F4,6,4,0.530701442681,STABLE +PLATE-1,F5,6,5,0.526764248567,UNSTABLE +PLATE-1,F6,6,6,0.535393254659,STABLE +PLATE-1,F7,6,7,0.485971393901,STABLE +PLATE-1,F8,6,8,0.446866206382,STABLE +PLATE-1,F9,6,9,0.500105016099,STABLE +PLATE-1,F10,6,10,0.572554837409,UNSTABLE +PLATE-1,F11,6,11,0.421581223622,UNSTABLE +PLATE-1,F12,6,12,0.566179719687,STABLE +PLATE-1,G1,7,1,0.597014347164,STABLE +PLATE-1,G2,7,2,0.595574322803,STABLE +PLATE-1,G3,7,3,0.573275879833,UNSTABLE +PLATE-1,G4,7,4,0.565598774935,UNSTABLE +PLATE-1,G5,7,5,0.580255468506,UNSTABLE +PLATE-1,G6,7,6,0.731126618477,UNSTABLE +PLATE-1,G7,7,7,0.586449329876,STABLE +PLATE-1,G8,7,8,0.504383391301,UNSTABLE +PLATE-1,G9,7,9,0.57029228861,UNSTABLE +PLATE-1,G10,7,10,0.571055758388,UNSTABLE +PLATE-1,G11,7,11,0.729508274912,STABLE +PLATE-1,G12,7,12,0.651282199669,UNSTABLE +PLATE-1,H1,8,1,0.708336042851,UNSTABLE +PLATE-1,H2,8,2,0.693510468853,STABLE +PLATE-1,H3,8,3,0.680500191339,UNSTABLE +PLATE-1,H4,8,4,0.682631399189,UNSTABLE +PLATE-1,H5,8,5,0.771686970996,UNSTABLE +PLATE-1,H6,8,6,0.592031721228,STABLE +PLATE-1,H7,8,7,0.683612608169,STABLE +PLATE-1,H8,8,8,0.632227578807,UNSTABLE +PLATE-1,H9,8,9,0.90031946922,UNSTABLE +PLATE-1,H10,8,10,0.750539227015,STABLE +PLATE-1,H11,8,11,0.826335733676,UNSTABLE +PLATE-1,H12,8,12,0.467946755513,UNSTABLE diff --git a/screening/sourceTest/core-plugins/FeatureVectorsDropboxTest/1/dss/drop-boxes/FeatureVectorsDropboxTest-drop-box/feature-vector-data-set-handler.py b/screening/sourceTest/core-plugins/FeatureVectorsDropboxTest/1/dss/drop-boxes/FeatureVectorsDropboxTest-drop-box/feature-vector-data-set-handler.py new file mode 100644 index 00000000000..d6059bd49ad --- /dev/null +++ b/screening/sourceTest/core-plugins/FeatureVectorsDropboxTest/1/dss/drop-boxes/FeatureVectorsDropboxTest-drop-box/feature-vector-data-set-handler.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +PLATE_GEOMETRY_PROPERTY_CODE = "$PLATE_GEOMETRY" +PLATE_GEOMETRY = "384_WELLS_16X24" + +""" +An Jython dropbox for importing HCS image datasets for use by the FeatureVectorsDropboxTest +""" + +import os +from java.util import Properties +from ch.systemsx.cisd.openbis.dss.etl.dto.api.v2 import SimpleFeatureVectorDataConfig +from java.io import File + +def create_experiment(tr): + space = tr.getSpace("TEST") + if space == None: + space = tr.createNewSpace("TEST", "etlserver") + project = tr.getProject("/TEST/TEST-PROJECT") + if project == None: + project = tr.createNewProject("/TEST/TEST-PROJECT") + expid = "/TEST/TEST-PROJECT/TRANSFORMED_THUMBNAILS_EXP" + + exp = tr.createNewExperiment(expid, 'SIRNA_HCS') + exp.setPropertyValue("DESCRIPTION", "Test experiment") + + return exp + +def create_plate(tr, experiment, plateCode): + plateId = "/TEST/" + plateCode + plate = tr.createNewSample(plateId, 'PLATE') + plate.setPropertyValue(PLATE_GEOMETRY_PROPERTY_CODE, PLATE_GEOMETRY) + plate.setExperiment(experiment) + + wellA1 = tr.createNewSample(plate.getSampleIdentifier() + ":A1", "SIRNA_WELL") + wellA1.setContainer(plate) + + wellA2 = tr.createNewSample(plate.getSampleIdentifier() + ":A2", "SIRNA_WELL") + wellA2.setContainer(plate) + + return plate + +def config_props(): + config = Properties() + config.setProperty("separator", ",") + config.setProperty("well-name-row", "Well") + config.setProperty("well-name-col", "Well") + config.setProperty("well-name-col-is-alphanum", "true") + return config + +def process(transaction): + experiment = create_experiment(transaction) + plate = create_plate(transaction, experiment, 'PLATE-FEATURE-VECTOR-TEST') + + configProps = config_props() + config = SimpleFeatureVectorDataConfig(configProps) + + featuresPath = os.path.join(transaction.getIncoming().getAbsolutePath(), "features.csv") + featureDataSet = transaction.createNewFeatureVectorDataSet(config, File(featuresPath)) + featureDataSet.setFileFormatType('CSV') + + featureDataSet.setSample(plate) + transaction.moveFile(featuresPath, featureDataSet) + + print featureDataSet \ No newline at end of file diff --git a/screening/sourceTest/core-plugins/FeatureVectorsDropboxTest/1/dss/drop-boxes/FeatureVectorsDropboxTest-drop-box/plugin.properties b/screening/sourceTest/core-plugins/FeatureVectorsDropboxTest/1/dss/drop-boxes/FeatureVectorsDropboxTest-drop-box/plugin.properties new file mode 100644 index 00000000000..900b82a6dbb --- /dev/null +++ b/screening/sourceTest/core-plugins/FeatureVectorsDropboxTest/1/dss/drop-boxes/FeatureVectorsDropboxTest-drop-box/plugin.properties @@ -0,0 +1,8 @@ +incoming-dir = ${root-dir}/incoming-FeatureVectorsDropboxTest +incoming-dir-create = true +incoming-data-completeness-condition = auto-detection +top-level-data-set-handler = ch.systemsx.cisd.openbis.dss.etl.jython.v2.JythonPlateDataSetHandlerV2 +script-path = feature-vector-data-set-handler.py +storage-processor = ch.systemsx.cisd.openbis.dss.etl.PlateStorageProcessor +storage-processor.processor = ch.systemsx.cisd.etlserver.DefaultStorageProcessor +storage-processor.data-source = imaging-db \ No newline at end of file diff --git a/screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/FeatureVectorsDropboxTest.java b/screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/FeatureVectorsDropboxTest.java new file mode 100644 index 00000000000..f7cc1a1bba2 --- /dev/null +++ b/screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/FeatureVectorsDropboxTest.java @@ -0,0 +1,129 @@ +/* + * 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.screening.systemtests; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import org.apache.commons.io.FileUtils; +import org.springframework.mock.web.MockHttpServletRequest; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import ch.systemsx.cisd.common.filesystem.FileUtilities; +import ch.systemsx.cisd.common.servlet.SpringRequestContextProvider; +import ch.systemsx.cisd.openbis.plugin.screening.client.api.v1.IScreeningOpenbisServiceFacade; +import ch.systemsx.cisd.openbis.plugin.screening.client.api.v1.ScreeningOpenbisServiceFacade; +import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.IScreeningClientService; +import ch.systemsx.cisd.openbis.plugin.screening.shared.ResourceNames; +import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.IScreeningApiServer; +import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.FeatureVectorDatasetReference; +import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto.Plate; + +/** + * @author Chandrasekhar Ramakrishnan + */ +@Test(groups = + { "slow", "systemtest" }) +public class FeatureVectorsDropboxTest extends AbstractScreeningSystemTestCase +{ + private MockHttpServletRequest request; + + private String sessionToken; + + private IScreeningClientService screeningClientService; + + private IScreeningApiServer screeningServer; + + private IScreeningOpenbisServiceFacade screeningFacade; + + @BeforeTest + public void dropAnExampleDataSet() throws IOException, Exception + { + File exampleDataSet = createTestDataContents(); + moveFileToIncoming(exampleDataSet); + waitUntilDataSetImported(); + } + + @BeforeMethod + public void setUp() throws Exception + { + screeningClientService = + (IScreeningClientService) applicationContext + .getBean(ResourceNames.SCREENING_PLUGIN_SERVICE); + request = new MockHttpServletRequest(); + ((SpringRequestContextProvider) applicationContext.getBean("request-context-provider")) + .setRequest(request); + Object bean = applicationContext.getBean(ResourceNames.SCREENING_PLUGIN_SERVER); + screeningServer = (IScreeningApiServer) bean; + sessionToken = screeningClientService.tryToLogin("admin", "a").getSessionID(); + screeningFacade = ScreeningOpenbisServiceFacade.tryCreateForTest(sessionToken, "http://localhost:" + SYSTEM_TEST_CASE_SERVER_PORT, screeningServer); + } + + @AfterMethod + public void tearDown() + { + File[] files = getIncomingDirectory().listFiles(); + for (File file : files) + { + FileUtilities.deleteRecursively(file); + } + } + + @Test + public void testFeatureVectors() throws Exception + { + List<Plate> plates = screeningFacade.listPlates(); + + List<FeatureVectorDatasetReference> features = + screeningFacade.listFeatureVectorDatasets(plates); + + // exactly one feature vector data set should be created in this test + assertEquals(1, features.size()); + + FeatureVectorDatasetReference feature = features.get(0); + assertEquals("HCS_ANALYSIS_CONTAINER_WELL_FEATURES", feature.getDataSetType()); + + } + + private File createTestDataContents() throws IOException + { + File dest = new File(workingDirectory, "test-data"); + dest.mkdirs(); + + File featureSrc = getFeatureVectorsTestData(); + FileUtils.copyFileToDirectory(featureSrc, dest); + // Copy the test data set to the location for processing + return dest; + } + + private File getFeatureVectorsTestData() + { + return new File("../screening/resource/test-data/FeatureVectorsDropboxTest/", + "features.csv"); + } + + @Override + protected int dataSetImportWaitDurationInSeconds() + { + return 60; + } + +} -- GitLab