Skip to content
Snippets Groups Projects
Commit 75e01f8b authored by kaloyane's avatar kaloyane
Browse files

[LMS-2401] parse analysis procedures from GE XML file

SVN: 22256
parent ad21695f
No related branches found
No related tags found
No related merge requests found
......@@ -373,7 +373,8 @@ if incoming.isDirectory():
analysisFile = util.findFileByExt(incoming, "xml")
if analysisFile is not None:
analysisCSVFile = File(analysisFile.getPath() + ".csv")
GEExplorerImageAnalysisResultParser(analysisFile.getPath()).writeCSV(analysisCSVFile)
geXmlParser = GEExplorerImageAnalysisResultParser(analysisFile.getPath())
geXmlParser.writeCSV(analysisCSVFile)
featureProps = Properties()
featureProps.setProperty("separator", ",")
......@@ -381,7 +382,7 @@ if incoming.isDirectory():
featureProps.setProperty("well-name-col", "Well")
analysisDataSetDetails = factory.createFeatureVectorRegistrationDetails(analysisCSVFile.getPath(), featureProps)
analysisProcedureCode = util.extractFileBasename(analysisFile.getName())
analysisProcedureCode = geXmlParser.getAnalysisProcedureName()
analysisDataSetDetails.getDataSetInformation().setAnalysisProcedure(analysisProcedureCode)
analysisDataSet = transaction.createNewDataSet(analysisDataSetDetails)
analysisDataSet.setSample(imageDataSet.getSample())
......
......@@ -404,6 +404,8 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest
NewExternalData analysisDataSet = dataSetsRegistered.get(2);
assertEquals(ANALYSIS_DATA_SET_CODE, analysisDataSet.getCode());
assertEquals(ANALYSIS_DATA_SET_TYPE, analysisDataSet.getDataSetType());
assertEquals("NRF2ProdAnalysis_1.1_MatlabGeneral_1.1",
extractAnalysisProcedureCode(analysisDataSet));
AssertionUtil
......@@ -414,6 +416,14 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest
context.assertIsSatisfied();
}
private String extractAnalysisProcedureCode(NewExternalData analysisDataSet)
{
NewProperty property =
EntityHelper.tryFindProperty(analysisDataSet.getDataSetProperties(),
ScreeningConstants.ANALYSIS_PROCEDURE);
return (property != null) ? property.getValue() : null;
}
@Test
public void testFatalErrorSentToAdmin() throws IOException
{
......
......@@ -31,6 +31,7 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.apache.commons.lang.StringUtils;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
......@@ -49,17 +50,23 @@ public class GEExplorerImageAnalysisResultParser extends DefaultHandler
private static final String WELL_TAG = "Well";
private static final String TABLE_TAG = "Table";
private static final String DATA_TAG = "Data";
private static final String ANALYSIS_TAG = "AutoLeadAnalysisProtocol";
private static final String ASSAY_TAG = "AutoLeadAssay";
private enum State
{
INIT, DATA, TABLE, WELL, FINISHED
INIT, ANALYSIS, DATA, TABLE, WELL, FINISHED
}
private State state = State.INIT;
private String analysisProtocolWithVersion = StringUtils.EMPTY;
private String assayWithVersion = StringUtils.EMPTY;
private String currentWellId;
private HashSet<String> wells = new HashSet<String>();
......@@ -99,8 +106,16 @@ public class GEExplorerImageAnalysisResultParser extends DefaultHandler
}
break;
case DATA:
if (TABLE_TAG.equals(qName) && "Wells Summary".equals(attributes.getValue("title")))
if (ANALYSIS_TAG.equals(qName))
{
analysisProtocolWithVersion = parseNameAndVersion(attributes);
state = State.ANALYSIS;
}
break;
case ANALYSIS:
if (ASSAY_TAG.equals(qName))
{
assayWithVersion = parseNameAndVersion(attributes);
state = State.TABLE;
}
break;
......@@ -224,4 +239,35 @@ public class GEExplorerImageAnalysisResultParser extends DefaultHandler
out.close();
}
public String getAnalysisProcedureName()
{
if (StringUtils.isEmpty(assayWithVersion))
{
return analysisProtocolWithVersion;
} else
{
return analysisProtocolWithVersion + "_" + assayWithVersion;
}
}
private String parseNameAndVersion(Attributes attributes)
{
String name = parseAttribute("name", attributes);
String version = parseAttribute("version", attributes);
if (StringUtils.isEmpty(version))
{
return name;
} else
{
return name + "_" + version;
}
}
private String parseAttribute(String attrName, Attributes attributes)
{
String attrValue = attributes.getValue(attrName);
return StringUtils.trimToEmpty(attrValue);
}
}
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