Skip to content

Commit

Permalink
First PoC for lipid ms lib parsing and validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilshoffmann committed Nov 1, 2023
1 parent 4d30d73 commit 1172474
Show file tree
Hide file tree
Showing 11 changed files with 542 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lipid_validation/mslibrary-lipid-validator/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

5 changes: 5 additions & 0 deletions lipid_validation/mslibrary-lipid-validator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
83 changes: 83 additions & 0 deletions lipid_validation/mslibrary-lipid-validator/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.4/userguide/building_java_projects.html in the Gradle documentation.
*/

plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
maven {
url "https://m.lifs-tools.org/artifactory/libs-release"
}
maven { url = "file://" + projectDir + "/src/main/lib" }
// For jmzml, etc.
maven { url = "https://www.ebi.ac.uk/Tools/maven/repos/content/groups/ebi-repo/" }
// For SIRIUS ID modules
maven { url = "https://bio.informatik.uni-jena.de/repository/libs-oss/" }
maven { url = "https://jitpack.io" }
maven { url = "https://www.xypron.de/repository/" }
// For cpdetector
maven { url = "https://nexus.nuiton.org/nexus/content/groups/releases/" }
// For jimzml
// maven { url = "https://mvnrepository.com/artifact/com.alanmrace/jimzmlparser" }
}

ext {
jgoslinVersion = '2.1.0'
}

dependencies {
// Use JUnit Jupiter for testing.
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.3'

testRuntimeOnly 'org.junit.platform:junit-platform-launchchemspider-apier'

// This dependency is used by the application.
implementation 'com.google.guava:guava:32.1.1-jre'

implementation('io.github.mzmine:mzmine3:3.9.3') {
exclude group: 'org.rsc.chemspider', module: 'chemspider-api'
exclude group: 'mzmine', module: 'jmprojection'
exclude group: 'mzmine', module: 'gslibml'
exclude group: 'org.du-lab.adap', module: 'adap'
exclude group: 'gnf', module: 'clustering'
}
implementation "org.lifs-tools:jgoslin-parsers:$jgoslinVersion"
}

// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(20)
}
}

application {
// Define the main class for the application.
mainClass = 'org.mzmine.mslibrary.lipid.validator.App'
}

tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.compilerArgs += ['--enable-preview']
}

tasks.withType(Test) {
jvmArgs += "--enable-preview"
}

tasks.withType(JavaExec) {
jvmArgs += '--enable-preview'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package org.mzmine.mslibrary.lipid.validator;

import io.github.mzmine.util.spectraldb.parser.UnsupportedFormatException;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class App {

public String getGreeting() {
return "Hello World!";
}

public static void main(String[] args) {
try {
new MsLibraryReader().read(new File("/home/nilshoffmann/Projects/github.com/nilshoffmann/biohack23_p15/library_spectra_validation/tests/examples/test_case_correct.mgf"));
} catch (IOException ex) {
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnsupportedFormatException ex) {
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package org.mzmine.mslibrary.lipid.validator;

import io.github.mzmine.util.MemoryMapStorage;
import io.github.mzmine.util.spectraldb.entry.DBEntryField;
import io.github.mzmine.util.spectraldb.entry.SpectralLibrary;
import io.github.mzmine.util.spectraldb.parser.AutoLibraryParser;
import io.github.mzmine.util.spectraldb.parser.UnsupportedFormatException;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
import org.lifstools.jgoslin.domain.LipidParsingException;
import org.lifstools.jgoslin.parser.LipidParser;

/**
*
* @author nilshoffmann
*/
public class MsLibraryReader {

private final LipidParser lipidParser = new LipidParser();

public void read(File mgfFile) throws IOException, UnsupportedFormatException {
AutoLibraryParser alp = new AutoLibraryParser(10, (spectralLibraryEntryList, alreadyProcessed) -> {
spectralLibraryEntryList.forEach((t) -> {
String name = t.getField(DBEntryField.NAME).orElse("NA");
System.out.println("Processing entry: " + name);
try {
lipidParser.parse(name);
} catch (LipidParsingException e) {
System.out.println("");
}
});
});
String prefix = "lipid-spec-lib-" + UUID.randomUUID();
boolean parseSuccess = alp.parse(null, mgfFile, new SpectralLibrary(MemoryMapStorage.create(), prefix, File.createTempFile(prefix, ".slib")));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package org.mzmine.mslibrary.lipid.validator;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

class AppTest {
@Test void appHasAGreeting() {
App classUnderTest = new App();
assertNotNull(classUnderTest.getGreeting(), "app should have a greeting");
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 1172474

Please sign in to comment.