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

SE-147 data set is either the protXML file or a folder which contains a *prot.xml file

SVN: 12845
parent 49398df7
No related branches found
No related tags found
No related merge requests found
...@@ -34,6 +34,7 @@ import ch.systemsx.cisd.etlserver.IDataSetUploader; ...@@ -34,6 +34,7 @@ import ch.systemsx.cisd.etlserver.IDataSetUploader;
import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService; import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService;
import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetInformation; import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetInformation;
import ch.systemsx.cisd.openbis.etlserver.phosphonetx.dto.ProteinSummary; import ch.systemsx.cisd.openbis.etlserver.phosphonetx.dto.ProteinSummary;
import ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException;
/** /**
* @author Franz-Josef Elmer * @author Franz-Josef Elmer
...@@ -83,14 +84,26 @@ public class ProtXMLUploader implements IDataSetUploader ...@@ -83,14 +84,26 @@ public class ProtXMLUploader implements IDataSetUploader
public void upload(File dataSet, DataSetInformation dataSetInformation) public void upload(File dataSet, DataSetInformation dataSetInformation)
{ {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
ProteinSummary summary = loader.readProtXML(dataSet); File protXMLFile = getProtXMLFile(dataSet);
ProteinSummary summary = loader.readProtXML(protXMLFile);
if (operationLog.isInfoEnabled()) if (operationLog.isInfoEnabled())
{ {
operationLog.info(summary.getProteinGroups().size() operationLog.info(summary.getProteinGroups().size()
+ " protein groups are successfully read from '" + dataSet + "' in " + " protein groups are successfully read from '" + protXMLFile + "' in "
+ (System.currentTimeMillis() - time) + " msec"); + (System.currentTimeMillis() - time) + " msec");
} }
time = System.currentTimeMillis(); time = System.currentTimeMillis();
ResultDataSetUploader upLoader = createUploader();
upLoader.upload(dataSetInformation, summary);
if (operationLog.isInfoEnabled())
{
operationLog.info("Feeding result database took " + (System.currentTimeMillis() - time)
+ " msec.");
}
}
protected ResultDataSetUploader createUploader()
{
Connection connection; Connection connection;
try try
{ {
...@@ -100,13 +113,24 @@ public class ProtXMLUploader implements IDataSetUploader ...@@ -100,13 +113,24 @@ public class ProtXMLUploader implements IDataSetUploader
{ {
throw CheckedExceptionTunnel.wrapIfNecessary(ex); throw CheckedExceptionTunnel.wrapIfNecessary(ex);
} }
ResultDataSetUploader upLoader = new ResultDataSetUploader(connection, openbisService); return new ResultDataSetUploader(connection, openbisService);
upLoader.upload(dataSetInformation, summary); }
if (operationLog.isInfoEnabled())
private File getProtXMLFile(File dataSet)
{
if (dataSet.isDirectory() == false)
{ {
operationLog.info("Feeding result database took " + (System.currentTimeMillis() - time) return dataSet;
+ " msec."); }
File[] files = dataSet.listFiles();
for (File file : files)
{
if (file.getName().endsWith("prot.xml"))
{
return file;
}
} }
throw new UserFailureException("No *prot.xml file found in data set '" + dataSet + "'.");
} }
} }
...@@ -21,7 +21,6 @@ import java.util.List; ...@@ -21,7 +21,6 @@ import java.util.List;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase;
import ch.systemsx.cisd.common.filesystem.FileUtilities; import ch.systemsx.cisd.common.filesystem.FileUtilities;
import ch.systemsx.cisd.openbis.etlserver.phosphonetx.dto.AminoAcidMass; import ch.systemsx.cisd.openbis.etlserver.phosphonetx.dto.AminoAcidMass;
import ch.systemsx.cisd.openbis.etlserver.phosphonetx.dto.AnnotatedProtein; import ch.systemsx.cisd.openbis.etlserver.phosphonetx.dto.AnnotatedProtein;
...@@ -40,45 +39,8 @@ import ch.systemsx.cisd.openbis.etlserver.phosphonetx.dto.ProteinSummaryHeader; ...@@ -40,45 +39,8 @@ import ch.systemsx.cisd.openbis.etlserver.phosphonetx.dto.ProteinSummaryHeader;
* *
* @author Franz-Josef Elmer * @author Franz-Josef Elmer
*/ */
public class ProtXMLLoaderTest extends AbstractFileSystemTestCase public class ProtXMLLoaderTest extends ProtXMLTestCase
{ {
private static final String EXAMPLE = "<?xml version='1.0' encoding='UTF-8'?>\n"
+ "<protein_summary xmlns='http://regis-web.systemsbiology.net/protXML' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://sashimi.sourceforge.net/schema_revision/protXML/protXML_v3.xsd'>\n"
+ "<protein_summary_header reference_database='some/path/uniprot.HUMAN.v125.fasta'>\n"
+ " <program_details>\n"
+ " <proteinprophet_details >\n"
+ " <protein_summary_data_filter min_probability='0.25' sensitivity='1' false_positive_error_rate='0.5' predicted_num_correct='9' predicted_num_incorrect='4'/>\n"
+ " </proteinprophet_details >\n"
+ " </program_details>\n"
+ "</protein_summary_header>\n"
+ "<protein_group probability='1'>\n"
+ " <protein probability='1'>\n"
+ " <parameter name='key1' value='value1' type='type1'/>\n"
+ " <parameter name='key2' value='value2' type='type2'/>\n"
+ " <annotation protein_description='P42'/>\n"
+ " <indistinguishable_protein><annotation protein_description='P43'/></indistinguishable_protein>\n"
+ " <indistinguishable_protein><annotation protein_description='P44'/></indistinguishable_protein>\n"
+ " <peptide peptide_sequence='VYQIDGNYSR'>\n"
+ " <modification_info mod_nterm_mass='42' mod_cterm_mass='24.25'>\n"
+ " <mod_aminoacid_mass position='1' mass='115.25'/>\n"
+ " <mod_aminoacid_mass position='4' mass='31.75'/>\n"
+ " </modification_info>\n"
+ " </peptide>\n"
+ " <peptide peptide_sequence='ITSN'/>\n"
+ " </protein>\n"
+ " <protein probability='0'>\n"
+ " <annotation protein_description='Q42'/>\n"
+ " <peptide peptide_sequence='YSR'/>\n"
+ " </protein>\n"
+ "</protein_group>\n"
+ "<protein_group probability='0.75'>\n"
+ " <protein probability='0.75'>\n"
+ " <annotation protein_description='R42'/>\n"
+ " <peptide peptide_sequence='IYSR'/>\n"
+ " </protein>\n"
+ "</protein_group>\n"
+ "</protein_summary>\n";
@Test @Test
public void test() public void test()
{ {
......
/*
* Copyright 2009 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.etlserver.phosphonetx;
import ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase;
/**
*
*
* @author Franz-Josef Elmer
*/
public abstract class ProtXMLTestCase extends AbstractFileSystemTestCase
{
protected static final String EXAMPLE = "<?xml version='1.0' encoding='UTF-8'?>\n"
+ "<protein_summary xmlns='http://regis-web.systemsbiology.net/protXML' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://sashimi.sourceforge.net/schema_revision/protXML/protXML_v3.xsd'>\n"
+ "<protein_summary_header reference_database='some/path/uniprot.HUMAN.v125.fasta'>\n"
+ " <program_details>\n"
+ " <proteinprophet_details >\n"
+ " <protein_summary_data_filter min_probability='0.25' sensitivity='1' false_positive_error_rate='0.5' predicted_num_correct='9' predicted_num_incorrect='4'/>\n"
+ " </proteinprophet_details >\n"
+ " </program_details>\n"
+ "</protein_summary_header>\n"
+ "<protein_group probability='1'>\n"
+ " <protein probability='1'>\n"
+ " <parameter name='key1' value='value1' type='type1'/>\n"
+ " <parameter name='key2' value='value2' type='type2'/>\n"
+ " <annotation protein_description='P42'/>\n"
+ " <indistinguishable_protein><annotation protein_description='P43'/></indistinguishable_protein>\n"
+ " <indistinguishable_protein><annotation protein_description='P44'/></indistinguishable_protein>\n"
+ " <peptide peptide_sequence='VYQIDGNYSR'>\n"
+ " <modification_info mod_nterm_mass='42' mod_cterm_mass='24.25'>\n"
+ " <mod_aminoacid_mass position='1' mass='115.25'/>\n"
+ " <mod_aminoacid_mass position='4' mass='31.75'/>\n"
+ " </modification_info>\n"
+ " </peptide>\n"
+ " <peptide peptide_sequence='ITSN'/>\n"
+ " </protein>\n"
+ " <protein probability='0'>\n"
+ " <annotation protein_description='Q42'/>\n"
+ " <peptide peptide_sequence='YSR'/>\n"
+ " </protein>\n"
+ "</protein_group>\n"
+ "<protein_group probability='0.75'>\n"
+ " <protein probability='0.75'>\n"
+ " <annotation protein_description='R42'/>\n"
+ " <peptide peptide_sequence='IYSR'/>\n"
+ " </protein>\n"
+ "</protein_group>\n"
+ "</protein_summary>\n";
/**
*
*
*/
public ProtXMLTestCase()
{
super();
}
/**
*
*
* @param cleanAfterMethod
*/
public ProtXMLTestCase(boolean cleanAfterMethod)
{
super(cleanAfterMethod);
}
}
\ No newline at end of file
/*
* Copyright 2009 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.etlserver.phosphonetx;
import java.io.File;
import java.util.Properties;
import org.jmock.Mockery;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import ch.systemsx.cisd.common.filesystem.FileUtilities;
import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService;
import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetInformation;
import ch.systemsx.cisd.openbis.etlserver.phosphonetx.dto.ProteinSummary;
import ch.systemsx.cisd.openbis.etlserver.phosphonetx.dto.ProteinSummaryHeader;
import ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException;
/**
*
*
* @author Franz-Josef Elmer
*/
public class ProtXMLUploaderTest extends ProtXMLTestCase
{
private static final class MockUploader extends ProtXMLUploader
{
private final IEncapsulatedOpenBISService openbisService;
private DataSetInformation dataSetInformation;
private ProteinSummary proteinSummary;
public MockUploader(Properties properties, IEncapsulatedOpenBISService openbisService)
{
super(properties, openbisService);
this.openbisService = openbisService;
}
@Override
protected ResultDataSetUploader createUploader()
{
return new ResultDataSetUploader(null, null, null)
{
@Override
void upload(DataSetInformation dataSetInfo, ProteinSummary summary)
{
dataSetInformation = dataSetInfo;
proteinSummary = summary;
}
};
}
public IEncapsulatedOpenBISService getService()
{
return openbisService;
}
public DataSetInformation getDataSetInformation()
{
return dataSetInformation;
}
public ProteinSummary getProteinSummary()
{
return proteinSummary;
}
}
private Mockery context;
private IEncapsulatedOpenBISService service;
private MockUploader uploader;
@BeforeMethod
public void startUp()
{
context = new Mockery();
service = context.mock(IEncapsulatedOpenBISService.class);
Properties properties = new Properties();
properties.setProperty("database.kind", "test");
uploader = new MockUploader(properties, service);
}
@AfterMethod
public void afterMethod()
{
// To following line of code should also be called at the end of each test method.
// Otherwise one do not known which test failed.
context.assertIsSatisfied();
}
@Test
public void testDataSetIsProtXMLFile()
{
File file = new File(workingDirectory, "test.xml");
FileUtilities.writeToFile(file, EXAMPLE);
DataSetInformation dataSetInformation = new DataSetInformation();
uploader.upload(file, dataSetInformation);
assertSame(service, uploader.getService());
assertSame(dataSetInformation, uploader.getDataSetInformation());
ProteinSummaryHeader header = uploader.getProteinSummary().getSummaryHeader();
assertEquals("some/path/uniprot.HUMAN.v125.fasta", header.getReferenceDatabase());
context.assertIsSatisfied();
}
@Test
public void testDataSetIsFolderWithProtXMLFile()
{
File dataSet = new File(workingDirectory, "data-set");
dataSet.mkdir();
FileUtilities.writeToFile(new File(dataSet, "test-prot.xml"), EXAMPLE);
DataSetInformation dataSetInformation = new DataSetInformation();
uploader.upload(dataSet, dataSetInformation);
assertSame(service, uploader.getService());
assertSame(dataSetInformation, uploader.getDataSetInformation());
ProteinSummaryHeader header = uploader.getProteinSummary().getSummaryHeader();
assertEquals("some/path/uniprot.HUMAN.v125.fasta", header.getReferenceDatabase());
context.assertIsSatisfied();
}
@Test
public void testDataSetIsFolderWithoutProtXMLFile()
{
File dataSet = new File(workingDirectory, "data-set");
dataSet.mkdir();
FileUtilities.writeToFile(new File(dataSet, "pep.xml"), "peptides");
DataSetInformation dataSetInformation = new DataSetInformation();
try
{
uploader.upload(dataSet, dataSetInformation);
fail("UserFailureException expected");
} catch (UserFailureException ex)
{
assertEquals(
"No *prot.xml file found in data set "
+ "'targets/unit-test-wd/ch.systemsx.cisd.openbis.etlserver.phosphonetx.ProtXMLUploaderTest/data-set'.",
ex.getMessage());
}
context.assertIsSatisfied();
}
}
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