Skip to content
Snippets Groups Projects
Commit 6cd595c0 authored by tpylak's avatar tpylak
Browse files

LMS-1397 yeastx: introduce label, mz1 and mz2 columns

SVN: 15051
parent dd677e23
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@ import javax.sql.DataSource;
import net.lemnik.eodsql.DataIterator;
import net.lemnik.eodsql.QueryTool;
import ch.rinn.restrictions.Private;
import ch.systemsx.cisd.dbmigration.DatabaseConfigurationContext;
import ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard.AbstractDatastorePlugin;
import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.IReportingPluginTask;
......@@ -49,7 +50,7 @@ public class EICMLChromatogramImagesReporter extends AbstractDatastorePlugin imp
private static final String CHROMATOGRAM_SERVLET = "chromatogram";
private static final int THUMBNAIL_WIDTH = 150;
private static final int THUMBNAIL_HEIGHT = 150;
private static final int IMAGE_WIDTH = 1066;
......@@ -61,7 +62,7 @@ public class EICMLChromatogramImagesReporter extends AbstractDatastorePlugin imp
private final IEICMSRunDAO query;
/**
* An internal helper class for storing the information for the query paramters to the image
* An internal helper class for storing the information for the query parameters to the image
* servlet.
*
* @author Chandrasekhar Ramakrishnan
......@@ -169,12 +170,68 @@ public class EICMLChromatogramImagesReporter extends AbstractDatastorePlugin imp
imageCell.addParameter(EICMLChromatogramGeneratorServlet.CHROMATOGRAM_CODE_PARAM,
chromatogram.getId());
String chromatogramLabel = chromatogram.getLabel();
row.add(SimpleTableModelBuilder.asText(chromatogramLabel));
int mz1 = getMz1(chromatogramLabel);
row.add(SimpleTableModelBuilder.asNum(mz1));
int mz2 = getMz2(chromatogramLabel);
row.add(SimpleTableModelBuilder.asNum(mz2));
row.add(imageCell);
return row;
}
// All eic_chromatograms.label values have a format [-]EIC mz1[>mz2].
@Private
static int getMz1(String chromatogramLabel)
{
String textBefore = "EIC ";
int ixEic = chromatogramLabel.indexOf(textBefore);
if (ixEic == -1)
{
return -1;
}
int ixGt = chromatogramLabel.indexOf(">");
if (ixGt == -1)
{
ixGt = chromatogramLabel.length();
}
if (ixGt < ixEic)
{
return -1;
}
String text = chromatogramLabel.substring(ixEic + textBefore.length(), ixGt);
return parseNumber(text, -1);
}
// All eic_chromatograms.label values have a format [-]EIC mz1[>mz2].
@Private
static int getMz2(String chromatogramLabel)
{
int ixGt = chromatogramLabel.indexOf(">");
if (ixGt == -1)
{
return -1;
}
String text = chromatogramLabel.substring(ixGt + 1);
return parseNumber(text, -1);
}
private static int parseNumber(String text, int defaultValue)
{
try
{
return Integer.parseInt(text);
} catch (NumberFormatException ex)
{
return defaultValue;
}
}
private static void addReportHeaders(SimpleTableModelBuilder builder)
{
builder.addHeader("Label");
builder.addHeader("m/z 1");
builder.addHeader("m/z 2");
builder.addHeader("Chromatogram");
}
}
/*
* Copyright 2010 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.yeastx.eicml;
import static ch.systemsx.cisd.yeastx.eicml.EICMLChromatogramImagesReporter.getMz1;
import static ch.systemsx.cisd.yeastx.eicml.EICMLChromatogramImagesReporter.getMz2;
import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.Test;
import ch.rinn.restrictions.Friend;
/**
* Test of {@link EICMLChromatogramImagesReporter}
*
* @author Tomasz Pylak
*/
@Friend(toClasses = EICMLChromatogramImagesReporter.class)
public class EICMLChromatogramImagesReporterTest
{
@Test
public void testLabelParsing()
{
assertEquals(10, getMz1("-EIC 10>23"));
assertEquals(10, getMz1("EIC 10>23"));
assertEquals(10, getMz1("-EIC 10"));
assertEquals(23, getMz2("-EIC 10>23"));
assertEquals(23, getMz2("EIC 10>23"));
assertEquals(-1, getMz2("-EIC 10"));
}
}
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