diff --git a/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/featurevector/FeatureVectorStorageProcessorConfiguration.java b/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/featurevector/FeatureVectorStorageProcessorConfiguration.java index d6780668f8410bb8b8fecdaa5a8871bab141ee4f..19e5942378ef698975f6d72d8c740285a3d99c37 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/featurevector/FeatureVectorStorageProcessorConfiguration.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/featurevector/FeatureVectorStorageProcessorConfiguration.java @@ -21,12 +21,17 @@ import java.util.HashSet; import java.util.Properties; import java.util.Set; +import ch.rinn.restrictions.Private; import ch.systemsx.cisd.common.utilities.PropertyUtils; import ch.systemsx.cisd.utils.CsvFileReaderHelper.ICsvFileReaderConfiguration; class FeatureVectorStorageProcessorConfiguration implements ICsvFileReaderConfiguration { + private static final String DEFAULT_COLUMNS_TO_BE_IGNORED = "barcode"; + + @Private static final String COLUMNS_TO_BE_IGNORED_KEY = "columns-to-be-ignored"; + private static final String SEPARATOR_PROPERTY_KEY = "separator"; private static final String IGNORE_COMMENTS_PROPERTY_KEY = "ignore-comments"; @@ -67,8 +72,8 @@ class FeatureVectorStorageProcessorConfiguration implements this.wellColumn = properties.getProperty(WELL_NAME_COL_PROPERTY_KEY, DEFAULT_WELL_COL); columnsToBeIgnored = - new HashSet<String>(Arrays.asList(properties.getProperty("columns-to-be-ignored", - "barcode").split(", *"))); + new HashSet<String>(Arrays.asList(properties.getProperty(COLUMNS_TO_BE_IGNORED_KEY, + DEFAULT_COLUMNS_TO_BE_IGNORED).split(", *"))); } public char getColumnDelimiter() diff --git a/screening/sourceTest/java/ch/systemsx/cisd/openbis/dss/etl/featurevector/CsvToCanonicalFeatureVectorTest.java b/screening/sourceTest/java/ch/systemsx/cisd/openbis/dss/etl/featurevector/CsvToCanonicalFeatureVectorTest.java index bca493c1e9deb3e8f4982b8b51f80e19135cbbbe..3baa0e8afd9e7acd411e9f07052af4367247b030 100644 --- a/screening/sourceTest/java/ch/systemsx/cisd/openbis/dss/etl/featurevector/CsvToCanonicalFeatureVectorTest.java +++ b/screening/sourceTest/java/ch/systemsx/cisd/openbis/dss/etl/featurevector/CsvToCanonicalFeatureVectorTest.java @@ -16,18 +16,22 @@ package ch.systemsx.cisd.openbis.dss.etl.featurevector; +import static ch.systemsx.cisd.openbis.dss.etl.featurevector.FeatureVectorStorageProcessorConfiguration.COLUMNS_TO_BE_IGNORED_KEY; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; +import java.util.Properties; import org.testng.AssertJUnit; import org.testng.annotations.Test; import com.csvreader.CsvReader; +import ch.rinn.restrictions.Friend; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.openbis.dss.etl.featurevector.CsvToCanonicalFeatureVector.CsvToCanonicalFeatureVectorConfiguration; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.DatasetFileLines; @@ -39,6 +43,7 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.imaging.dataaccess.ImgFe /** * @author Chandrasekhar Ramakrishnan */ +@Friend(toClasses=FeatureVectorStorageProcessorConfiguration.class) public class CsvToCanonicalFeatureVectorTest extends AssertJUnit { @Test @@ -77,6 +82,44 @@ public class CsvToCanonicalFeatureVectorTest extends AssertJUnit assertEquals(0.001052f, darr.getForWellLocation(2, 1)); } + @Test + public void testIgnoringColumns() throws IOException + { + Properties properties = new Properties(); + properties.setProperty(COLUMNS_TO_BE_IGNORED_KEY, "RelativeInfectionIndex, Log2RelativeInfectionIndex,ZScore"); + CsvToCanonicalFeatureVectorConfiguration config = + new CsvToCanonicalFeatureVectorConfiguration(new FeatureVectorStorageProcessorConfiguration(properties)); + CsvToCanonicalFeatureVector converter = + new CsvToCanonicalFeatureVector(getDatasetFileLines(), config, 16, 24); + ArrayList<CanonicalFeatureVector> fvs = converter.convert(); + // Not all the columns are not empty + assertEquals(15, fvs.size()); + // Check total cells feature + CanonicalFeatureVector totalCells = fvs.get(0); + ImgFeatureDefDTO def = totalCells.getFeatureDef(); + assertEquals("TotalCells", def.getLabel()); + assertEquals(1, totalCells.getValues().size()); + ImgFeatureValuesDTO values = totalCells.getValues().get(0); + PlateFeatureValues darr = values.getValues(); + assertTrue("Dimensions are " + darr.getGeometry().toPlateGeometryStr(), + Geometry.GEOMETRY_384_16X24.equals(darr.getGeometry())); + assertEquals(2825.0f, darr.getForWellLocation(1, 1)); + assertEquals(5544.0f, darr.getForWellLocation(1, 2)); + assertEquals(5701.0f, darr.getForWellLocation(2, 1)); + // Check InfectionIndex + CanonicalFeatureVector infectionIndex = fvs.get(2); + def = infectionIndex.getFeatureDef(); + assertEquals("InfectionIndex", def.getLabel()); + assertEquals(1, infectionIndex.getValues().size()); + values = infectionIndex.getValues().get(0); + darr = values.getValues(); + assertTrue("Dimensions are " + darr.getGeometry().toPlateGeometryStr(), + Geometry.GEOMETRY_384_16X24.equals(darr.getGeometry())); + assertEquals(0.009558f, darr.getForWellLocation(1, 1)); + assertEquals(0.037157f, darr.getForWellLocation(1, 2)); + assertEquals(0.001052f, darr.getForWellLocation(2, 1)); + } + /** * Return the tabular data as a DatasetFileLines. */