Skip to content

Commit

Permalink
Add basic metadata for MALDI-TOF MS spectra
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender committed Feb 21, 2022
1 parent 82a5d7f commit 3a653b0
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;

Expand Down Expand Up @@ -103,13 +106,19 @@ private void readDescription(Element element, IVendorMassSpectrum massSpectrum)
Node node = descriptionList.item(i);
Element description = (Element)node;
massSpectrum.setIdentifier(description.getElementsByTagName("title").item(0).getTextContent());
// TODO store and display
description.getElementsByTagName("date").item(0).getAttributes().getNamedItem("value").getTextContent();
description.getElementsByTagName("operator").item(0).getAttributes().getNamedItem("value").getTextContent();
description.getElementsByTagName("contact").item(0).getAttributes().getNamedItem("value").getTextContent();
description.getElementsByTagName("institution").item(0).getAttributes().getNamedItem("value").getTextContent();
description.getElementsByTagName("instrument").item(0).getAttributes().getNamedItem("value").getTextContent();
description.getElementsByTagName("notes").item(0).getTextContent();
try {
String date = description.getElementsByTagName("date").item(0).getAttributes().getNamedItem("value").getTextContent();
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy", Locale.ENGLISH);
massSpectrum.setAcquisitionDate(dateFormat.parse(date));
} catch(ParseException e) {
logger.warn(e);
}
String operator = description.getElementsByTagName("operator").item(0).getAttributes().getNamedItem("value").getTextContent();
String contact = description.getElementsByTagName("contact").item(0).getAttributes().getNamedItem("value").getTextContent();
String institution = description.getElementsByTagName("institution").item(0).getAttributes().getNamedItem("value").getTextContent();
massSpectrum.setOperator(operator + " " + contact + " " + institution);
massSpectrum.setInstrument(description.getElementsByTagName("instrument").item(0).getAttributes().getNamedItem("value").getTextContent());
description.getElementsByTagName("notes").item(0).getTextContent(); // TODO
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
package org.eclipse.chemclipse.msd.model.core;

import java.io.File;
import java.util.Date;

public abstract class AbstractVendorMassSpectrum extends AbstractRegularMassSpectrum implements IVendorMassSpectrum {

/**
* Renew the serialVersionUID any time you have changed some fields or
* methods.
*/
private static final long serialVersionUID = 5013842421250687341L;
private static final long serialVersionUID = 5013842421250687342L;
//
private File file;
private String operator;
private Date acquisitionDate;
private String instrument;

@Override
public File getFile() {
Expand Down Expand Up @@ -68,4 +72,40 @@ public void setRetentionTime(int retentionTime) {
super.setRetentionTime(retentionTime);
}
}

@Override
public String getOperator() {

return operator;
}

@Override
public void setOperator(String operator) {

this.operator = operator;
}

@Override
public Date getAcquisitionDate() {

return acquisitionDate;
}

@Override
public void setAcquisitionDate(Date acquisitionDate) {

this.acquisitionDate = acquisitionDate;
}

@Override
public String getInstrument() {

return instrument;
}

@Override
public void setInstrument(String instrument) {

this.instrument = instrument;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package org.eclipse.chemclipse.msd.model.core;

import java.io.File;
import java.util.Date;

/**
* More informations about the class structure of mass spectra are stored in {@link IScanMSD}.
Expand Down Expand Up @@ -74,4 +75,16 @@ public interface IVendorMassSpectrum extends IRegularMassSpectrum {
* @return int
*/
int getMaxPossibleRetentionTime();

String getOperator();

void setOperator(String operator);

Date getAcquisitionDate();

void setAcquisitionDate(Date acquisitionDate);

String getInstrument();

void setInstrument(String instrument);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 Lablicate GmbH.
* Copyright (c) 2020, 2022 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -12,6 +12,7 @@
package org.eclipse.chemclipse.ux.extension.xxd.ui;

import org.eclipse.chemclipse.msd.model.core.IVendorMassSpectrum;
import org.eclipse.chemclipse.support.text.ValueFormat;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
Expand All @@ -32,10 +33,15 @@ public void updateMassSpectrum(IVendorMassSpectrum massSpectrum) {
StringBuilder builder = new StringBuilder();
if(massSpectrum != null) {
addHeaderLine(builder, "Name", massSpectrum.getName());
addHeaderLine(builder, "Type Description", massSpectrum.getMassSpectrumTypeDescription());
addHeaderLine(builder, "Data", massSpectrum.getMassSpectrumTypeDescription());
addHeaderLine(builder, "File", massSpectrum.getFile().getName());
addHeaderLine(builder, "Mass Spectrometer", "MS" + massSpectrum.getMassSpectrometer());
addHeaderLine(builder, "Technique", "MS" + massSpectrum.getMassSpectrometer());
addHeaderLine(builder, "Instrument", massSpectrum.getInstrument());
addHeaderLine(builder, "Ions", Integer.toString(massSpectrum.getNumberOfIons()));
addHeaderLine(builder, "Operator", massSpectrum.getOperator());
if(massSpectrum.getAcquisitionDate() != null) {
addHeaderLine(builder, "Date", ValueFormat.getDateFormatEnglish().format(massSpectrum.getAcquisitionDate()));
}
}
//
text.setText(builder.toString());
Expand Down

0 comments on commit 3a653b0

Please sign in to comment.