Skip to content
This repository has been archived by the owner on May 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #761 from robinschmid/tomasmaster_gnps_new_fbmn_site
Browse files Browse the repository at this point in the history
[GNPS] New FBMN submission URL and GNPS GC-MS workflow in MZmine
  • Loading branch information
tomas-pluskal authored Nov 20, 2019
2 parents bc1071c + 8cf57c3 commit 5739e1b
Show file tree
Hide file tree
Showing 19 changed files with 127 additions and 79 deletions.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
6 changes: 4 additions & 2 deletions src/main/java/net/sf/mzmine/main/MZmineModulesList.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import net.sf.mzmine.modules.peaklistmethods.io.adap.mspexport.AdapMspExportModule;
import net.sf.mzmine.modules.peaklistmethods.io.csvexport.CSVExportModule;
import net.sf.mzmine.modules.peaklistmethods.io.gnpsexport.fbmn.GnpsFbmnExportAndSubmitModule;
import net.sf.mzmine.modules.peaklistmethods.io.gnpsexport.gc.GnpsGcExportAndSubmitModule;
import net.sf.mzmine.modules.peaklistmethods.io.metaboanalystexport.MetaboAnalystExportModule;
import net.sf.mzmine.modules.peaklistmethods.io.mztabexport.MzTabExportModule;
import net.sf.mzmine.modules.peaklistmethods.io.mztabimport.MzTabImportModule;
Expand Down Expand Up @@ -108,6 +109,7 @@
import net.sf.mzmine.modules.rawdatamethods.rawdataimport.RawDataImportModule;
import net.sf.mzmine.modules.rawdatamethods.sortdatafiles.SortDataFilesModule;
import net.sf.mzmine.modules.tools.isotopepatternpreview.IsotopePatternPreviewModule;
import net.sf.mzmine.modules.tools.kovats.KovatsIndexExtractionModule;
import net.sf.mzmine.modules.tools.msmsspectramerge.MsMsSpectraMergeModule;
import net.sf.mzmine.modules.tools.mzrangecalculator.MzRangeFormulaCalculatorModule;
import net.sf.mzmine.modules.tools.mzrangecalculator.MzRangeMassCalculatorModule;
Expand Down Expand Up @@ -197,7 +199,7 @@ public class MZmineModulesList {
AdapMspExportModule.class, //
AdapMgfExportModule.class, //
GnpsFbmnExportAndSubmitModule.class, //
// Not finished: GnpsGcExportAndSubmitModule.class, //
GnpsGcExportAndSubmitModule.class, //
SiriusExportModule.class, //

// Gap filling
Expand Down Expand Up @@ -286,7 +288,7 @@ public class MZmineModulesList {
MzRangeMassCalculatorModule.class, //
MzRangeFormulaCalculatorModule.class, //
IsotopePatternPreviewModule.class, //
// Not finished: KovatsIndexExtractionModule.class,
KovatsIndexExtractionModule.class, //

// all other regular MZmineModule (not MZmineRunnableModule) NOT LISTED IN MENU
SpectraIdentificationSpectralDatabaseModule.class, //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.apache.http.util.EntityUtils;
import org.json.JSONException;
import org.json.JSONObject;
import io.github.msdk.MSDKRuntimeException;
import net.sf.mzmine.modules.peaklistmethods.io.gnpsexport.fbmn.GnpsFbmnSubmitParameters;
import net.sf.mzmine.modules.peaklistmethods.io.gnpsexport.gc.GnpsGcSubmitParameters;
import net.sf.mzmine.util.files.FileAndPathUtil;
Expand All @@ -53,9 +52,9 @@ public class GNPSUtils {
private static final Logger LOG = Logger.getLogger(GNPSUtils.class.getName());

public static final String FBMN_SUBMIT_SITE =
"http://dorresteinappshub.ucsd.edu:5050/uploadanalyzefeaturenetworking";
"https://gnps-quickstart.ucsd.edu/uploadanalyzefeaturenetworking";
public static final String GC_SUBMIT_SITE =
"http://gnps-quickstart.ucsd.edu/uploadanalyzegcnetworking";
"https://gnps-quickstart.ucsd.edu/uploadanalyzegcnetworking";

/**
* Submit feature-based molecular networking (FBMN) job to GNPS
Expand All @@ -64,8 +63,7 @@ public class GNPSUtils {
* @param param
* @return
*/
public static String submitFbmnJob(File file, GnpsFbmnSubmitParameters param)
throws MSDKRuntimeException {
public static String submitFbmnJob(File file, GnpsFbmnSubmitParameters param) throws IOException {
// optional
boolean useMeta = param.getParameter(GnpsFbmnSubmitParameters.META_FILE).getValue();
boolean openWebsite = param.getParameter(GnpsFbmnSubmitParameters.OPEN_WEBSITE).getValue();
Expand Down Expand Up @@ -103,68 +101,59 @@ public static String submitFbmnJob(File file, GnpsFbmnSubmitParameters param)
*/
public static String submitFbmnJob(File mgf, File quan, File meta, File[] additionalEdges,
String title, String email, String username, String password, String presets,
boolean openWebsite) throws MSDKRuntimeException {
try {
// NEEDED files
if (mgf.exists() && quan.exists() && !presets.isEmpty()) {
CloseableHttpClient httpclient = HttpClients.createDefault();
boolean openWebsite) throws IOException {
// NEEDED files
if (mgf.exists() && quan.exists() && !presets.isEmpty()) {
CloseableHttpClient httpclient = HttpClients.createDefault();
try {
MultipartEntity entity = new MultipartEntity();

// ######################################################
// NEEDED
// tool, presets, quant table, mgf
entity.addPart("featuretool", new StringBody("MZMINE2"));
entity.addPart("description", new StringBody(title == null ? "" : title));
entity.addPart("networkingpreset", new StringBody(presets));
entity.addPart("featurequantification", new FileBody(quan));
entity.addPart("featurems2", new FileBody(mgf));

// ######################################################
// OPTIONAL
// email, meta data, additional edges
entity.addPart("email", new StringBody(email));
entity.addPart("username", new StringBody(username));
entity.addPart("password", new StringBody(password));
if (meta != null && meta.exists())
entity.addPart("samplemetadata", new FileBody(meta));

// add additional edges
if (additionalEdges != null)
for (File edge : additionalEdges)
if (edge != null && edge.exists())
entity.addPart("additionalpairs", new FileBody(edge));

HttpPost httppost = new HttpPost(FBMN_SUBMIT_SITE);
httppost.setEntity(entity);

LOG.info("Submitting GNPS job " + httppost.getRequestLine());
CloseableHttpResponse response = httpclient.execute(httppost);
try {
MultipartEntity entity = new MultipartEntity();

// ######################################################
// NEEDED
// tool, presets, quant table, mgf
entity.addPart("featuretool", new StringBody("MZMINE2"));
entity.addPart("description", new StringBody(title == null ? "" : title));
entity.addPart("networkingpreset", new StringBody(presets));
entity.addPart("featurequantification", new FileBody(quan));
entity.addPart("featurems2", new FileBody(mgf));

// ######################################################
// OPTIONAL
// email, meta data, additional edges
entity.addPart("email", new StringBody(email));
entity.addPart("username", new StringBody(username));
entity.addPart("password", new StringBody(password));
if (meta != null && meta.exists())
entity.addPart("samplemetadata", new FileBody(meta));

// add additional edges
if (additionalEdges != null)
for (File edge : additionalEdges)
if (edge != null && edge.exists())
entity.addPart("additionalpairs", new FileBody(edge));

// old address
// HttpPost httppost =
// new HttpPost("http://mingwangbeta.ucsd.edu:5050/uploadanalyzefeaturenetworking");
HttpPost httppost =
new HttpPost("http://dorresteinappshub.ucsd.edu:5050/uploadanalyzefeaturenetworking");
httppost.setEntity(entity);

LOG.info("Submitting GNPS job " + httppost.getRequestLine());
CloseableHttpResponse response = httpclient.execute(httppost);
try {
LOG.info("GNPS submit response status: " + response.getStatusLine());
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
LOG.info("GNPS submit response content length: " + resEntity.getContentLength());

// open job website
if (openWebsite)
openWebsite(resEntity);
EntityUtils.consume(resEntity);
}
} finally {
response.close();
LOG.info("GNPS submit response status: " + response.getStatusLine());
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
LOG.info("GNPS submit response content length: " + resEntity.getContentLength());

// open job website
if (openWebsite)
openWebsite(resEntity);
EntityUtils.consume(resEntity);
}
} finally {
httpclient.close();
response.close();
}
} finally {
httpclient.close();
}
} catch (IOException e) {
LOG.log(Level.SEVERE, "Error while submitting GNPS job", e);
throw new MSDKRuntimeException(e);
}
return "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private void submit(File fileName, GnpsFbmnSubmitParameters param) {
try {
String url = GNPSUtils.submitFbmnJob(fileName, param);
if (url == null || url.isEmpty())
LOG.log(Level.WARNING, "GNPS submit failed (url empty)");
LOG.log(Level.WARNING, "GNPS submit failed (response url empty)");
} catch (Exception e) {
LOG.log(Level.WARNING, "GNPS submit failed", e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<html>
<head>
<title>Export - GNPS Export/Submit</title>
<title>Export - Export/Submit to GNPS-FBMN</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="/net/sf/mzmine/desktop/impl/helpsystem/HelpStyles.css">
</head>
<body>

<h1>GNPS Export/Submit</h1>
<h1>Export/Submit to GNPS-FBMN</h1>

<h2>Description</h2>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@
import net.sf.mzmine.util.ExitCode;

/**
* Exports all files needed for GNPS feature based molecular networking (quant table (csv export)),
* MS2 mgf, additional edges (ion identity networks)
* Exports all files needed for GNPS GC-MS (quant table (csv export)), mgf (ADAP mgf export)
*
*
* @author Robin Schmid ([email protected])
*
*/
public class GnpsGcExportAndSubmitModule implements MZmineProcessingModule {
private final Logger LOG = Logger.getLogger(getClass().getName());

private static final String MODULE_NAME = "Export/Submit to GNPS-GC-MS (with ADAP)";
private static final String MODULE_NAME = "Export to GNPS-GC-MS (with ADAP)";
private static final String MODULE_DESCRIPTION =
"GNPS GC-EI-MS workflow. Export the mgf, quant table and Kovats reference file (optionally). Allows to directly submit to GNPS analysis.";
"GNPS GC-EI-MS workflow. Export the mgf, quant table and Kovats reference file (optionally).";

@Override
public String getDescription() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public class GnpsGcExportAndSubmitParameters extends SimpleParameterSet {


public GnpsGcExportAndSubmitParameters() {
super(new Parameter[] {PEAK_LISTS, FILENAME, REPRESENTATIVE_MZ, PEAK_INTENSITY, SUBMIT,
super(new Parameter[] {PEAK_LISTS, FILENAME, REPRESENTATIVE_MZ, PEAK_INTENSITY,
// SUBMIT,
OPEN_FOLDER});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ public class GnpsGcExportAndSubmitTask extends AbstractTask {
this.peakMeasure =
parameters.getParameter(GnpsGcExportAndSubmitParameters.PEAK_INTENSITY).getValue();
openFolder = parameters.getParameter(GnpsGcExportAndSubmitParameters.OPEN_FOLDER).getValue();
submit = parameters.getParameter(GnpsGcExportAndSubmitParameters.SUBMIT).getValue();
file = parameters.getParameter(GnpsGcExportAndSubmitParameters.FILENAME).getValue();
file = FileAndPathUtil.eraseFormat(file);
parameters.getParameter(GnpsGcExportAndSubmitParameters.FILENAME).setValue(file);
// submit = parameters.getParameter(GnpsGcExportAndSubmitParameters.SUBMIT).getValue();
submit = false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<html>
<head>
<title>Export - Export GNPS GC-MS (with ADAP)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="/net/sf/mzmine/desktop/impl/helpsystem/HelpStyles.css">
</head>
<body>

<h1>Export to GNPS GC-MS (with ADAP)</h1>

<h2>Description</h2>
<p>
The GNPS GC-MS module exports all files needed for the <strong>GC-MS</strong> workflow on the <a href="http://gnps.ucsd.edu/">GNPS web-platform</a>.
This includes the <strong>feature quantification table</strong> (CSV file) and the <strong>spectral summary</strong> (.MGF file) with representative clustered GC-EI-MS spectra for the row in an (aligned) feature list.
</p>

<h2>Instructions</h2>
<p>
Run this method on any (aligned) feature List. One of the spectral deconvolution methods need to be run (refer to the ADAP manual).
</p>


<h2>Parameters</h2>
<dl>
<dt>Filename</dt>
<dd>Base name for the output files</dd>

<dt>Representative m/z</dt>
<dd>The m/z value that is exported to the mgf and used in GNPS GC-MS (Options: As in feature table, highest m/z, heighest intensity)</dd>

<dt>Open folder</dt>
<dd>Opens the folder containing the output files</dd>
</dl>

<h2>Documentation</h2>
<p>
Please refer to the following documentation for a detailed tutorial:
<ul>
<li>If you use the <em>GNPS GC-MS</em> export please cite:
<ul>
<li>our upcoming paper on GC-MS within the GNPS environment: Aksenov et al.</li>
<li>the ADAP paper: Smirnov et al.: <a href="https://pubs.acs.org/doi/10.1021/acs.jproteome.7b00633">J. Proteome Res 2017, DOI: 10.1021/acs.jproteome.7b00633</a></li>
<li>the <a href="http://gnps.ucsd.edu/">GNPS</a> paper: Wang et al.: <a href="https://www.nature.com/nbt/journal/v34/n8/full/nbt.3597.html">Nature Biotechnology 34.8 (2016): 828-837</a><a href="http://gnps.ucsd.edu/">.</a></li>
<li>and the MZmine paper: Pluskal et al.: <a href="https://bmcbioinformatics.biomedcentral.com/articles/10.1186/1471-2105-11-395">BMC Bioinformatics, 11, 395 (2010)</a></li>
</ul>
</li>
<li><a href="https://ccms-ucsd.github.io/GNPSDocumentation/gc-ms-library-molecular-network/">See the documentation</a> about GC-MS within GNPS or <a href="https://ccms-ucsd.github.io/GNPSDocumentation">GNPS</a> on how to perform molecular networking, MS/MS spectral library search, and benefit from other tools available in GNPS environment.</li>
<li>Or check out the <a href="https://www.youtube.com/playlist?list=PL4L2Xw5k8ITwb4TzDKTAQ1UzrkVoBYkng">youtube playlist</a> on GNPS GC-MS (and MZmine) related videos</li>
</ul>
</p>

</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
import net.sf.mzmine.datamodel.RawDataFile;
import net.sf.mzmine.framework.listener.DelayedDocumentListener;
import net.sf.mzmine.main.MZmineCore;
import net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.view.ScanSelectPanel;
import net.sf.mzmine.modules.tools.kovats.KovatsValues.KovatsIndex;
import net.sf.mzmine.modules.tools.mzrangecalculator.MzRangeFormulaCalculatorModule;
import net.sf.mzmine.modules.visualization.tic.TICPlot;
Expand Down Expand Up @@ -508,13 +507,16 @@ private String getCsvTable(TreeMap<KovatsIndex, Double> values) {
StringBuilder s = new StringBuilder();
String nl = "\n";
// header for GNPS
s.append("Compound_Name,RT_Query" + nl);
// alkane name, num carbon(int), rt (seconds)
s.append("Compound_Name,Carbon_Number,RT" + nl);
DecimalFormat f = new DecimalFormat("0.##");

for (Entry<KovatsIndex, Double> e : values.entrySet()) {
s.append(e.getKey().getCombinedName());
s.append(e.getKey().getAlkaneName());
s.append(",");
// expor tin seconds for GNPS GC
s.append(String.valueOf(e.getKey().getNumCarbon()));
s.append(",");
// export rt in seconds for GNPS GC
s.append(f.format(e.getValue() * 60.0));
s.append(nl);
}
Expand Down Expand Up @@ -877,7 +879,7 @@ private void combineFiles() {


private static Icon createIcon(String path) {
return new ImageIcon(new ImageIcon(ScanSelectPanel.class.getClassLoader().getResource(path))
.getImage().getScaledInstance(SIZE, SIZE, Image.SCALE_SMOOTH));
return new ImageIcon(
new ImageIcon(path).getImage().getScaledInstance(SIZE, SIZE, Image.SCALE_SMOOTH));
}
}

0 comments on commit 5739e1b

Please sign in to comment.