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

add the option to get experiment from properties file instead of be generated automatically.

SVN: 28154
parent 61679f62
No related branches found
No related tags found
No related merge requests found
......@@ -47,7 +47,10 @@ public class DataSetInfoExtractorForProteinResults extends AbstractDataSetInfoEx
{
@Private
static final String EXPERIMENT_TYPE_CODE_KEY = "experiment-type-code";
@Private
static final String EXPERIMENT_CODE_KEY = "experiment-code";
@Private
static final String EXPERIMENT_PROPERTIES_FILE_NAME_KEY = "experiment-properties-file-name";
......@@ -103,15 +106,19 @@ public class DataSetInfoExtractorForProteinResults extends AbstractDataSetInfoEx
+ separator + "': " + name);
}
ProjectIdentifier projectIdentifier = new ProjectIdentifier(items[0], items[1]);
String experimentCode = service.generateCodes("E", EntityKind.EXPERIMENT, 1).get(0);
Properties properties =
loadSearchProperties(new File(incomingDataSetPath, experimentPropertiesFileName));
String experimentCode = properties.getProperty(EXPERIMENT_CODE_KEY);
if (experimentCode == null)
{
experimentCode = service.generateCodes("E", EntityKind.EXPERIMENT, 1).get(0);
}
ExperimentIdentifier experimentIdentifier =
new ExperimentIdentifier(projectIdentifier, experimentCode);
NewExperiment experiment =
new NewExperiment(experimentIdentifier.toString(), experimentTypeCode);
ExperimentType experimentType = service.getExperimentType(experimentTypeCode);
Properties properties =
loadSearchProperties(new File(incomingDataSetPath, experimentPropertiesFileName));
experiment.setProperties(Util.getAndCheckProperties(properties, experimentType));
DataSetInformation info = new DataSetInformation();
info.setExperimentIdentifier(experimentIdentifier);
......
......@@ -119,6 +119,32 @@ public class DataSetInfoExtractorForProteinResultsTest extends AbstractFileSyste
assertEquals("[1, 2, 3, 4]", info.getParentDataSetCodes().toString());
context.assertIsSatisfied();
}
@Test
public void testWithProvidedExperimentCode()
{
String propertiesFile = "my.properties";
FileUtilities.writeToFile(new File(dataSet, propertiesFile), "answer=42\nblabla=blub\n"
+ DataSetInfoExtractorForProteinResults.EXPERIMENT_CODE_KEY + "= MY_EXP1\n");
Properties properties = new Properties();
String experimentType = "MY_EXPERIMENT";
properties.setProperty(EXPERIMENT_TYPE_CODE_KEY, experimentType);
properties.setProperty(EXPERIMENT_PROPERTIES_FILE_NAME_KEY, propertiesFile);
prepare(experimentType, false);
context.checking(new Expectations()
{
{
one(service).registerExperiment(with(any(NewExperiment.class)));
}
});
IDataSetInfoExtractor extractor = createExtractor(properties);
DataSetInformation info = extractor.getDataSetInformation(dataSet, service);
assertEquals("/SPACE1/PROJECT1/MY_EXP1", info.getExperimentIdentifier().toString());
context.assertIsSatisfied();
}
@Test
public void testRegistrationWithOneMandatoryProperty()
......@@ -351,12 +377,20 @@ public class DataSetInfoExtractorForProteinResultsTest extends AbstractFileSyste
}
private void prepare(final String experimentType)
{
prepare(experimentType, true);
}
private void prepare(final String experimentType, final boolean experimentCodeGenerated)
{
context.checking(new Expectations()
{
{
one(service).generateCodes("E", EntityKind.EXPERIMENT, 1);
will(returnValue(Collections.singletonList("E4711")));
if (experimentCodeGenerated)
{
one(service).generateCodes("E", EntityKind.EXPERIMENT, 1);
will(returnValue(Collections.singletonList("E4711")));
}
one(service).getExperimentType(experimentType);
ExperimentType type = new ExperimentType();
......
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