Skip to content
Snippets Groups Projects
Commit 0a76e344 authored by felmer's avatar felmer
Browse files

LMS-1883 unit test for ignoring column property

SVN: 18948
parent f83c1b10
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
......@@ -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.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment