Skip to content

Commit

Permalink
Merge branch '50-new-persistence-model-classes-need-more-annotations'…
Browse files Browse the repository at this point in the history
… into 'master'

Resolve "new persistence model classes need more annotations"

Closes #50

See merge request bright-giant/sirius/sirius-libs!23
  • Loading branch information
Markus Fleischauer committed Nov 16, 2023
2 parents 7b11aa2 + 13257dd commit ed2cea9
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

package de.unijena.bioinf.ChemistryBase.ms;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Range;

import java.util.Locale;
Expand All @@ -30,7 +31,7 @@ public class IsolationWindow {
protected final double windowWidth;


public IsolationWindow(double windowOffset, double windowWidth) {
public IsolationWindow(@JsonProperty("windowOffset") double windowOffset, @JsonProperty("windowWidth") double windowWidth) {
this.windowOffset = windowOffset;
this.windowWidth = windowWidth;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package de.unijena.bioinf.ms.persistence.model.core;

import de.unijena.bioinf.ChemistryBase.ms.utils.SimpleSpectrum;
import jakarta.persistence.Id;
import lombok.*;

/**
Expand All @@ -31,6 +30,7 @@
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class AbstractScan {
/**
* Database ID of the Run this Scan belongs to
Expand All @@ -55,5 +55,6 @@ public class AbstractScan {
/**
* The actual spectrum that has been measured (masses and intensities)
*/
@ToString.Exclude
protected SimpleSpectrum peaks;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
@AllArgsConstructor
@Builder
@JsonAutoDetect(fieldVisibility = ANY, getterVisibility = NONE, setterVisibility = NONE, isGetterVisibility = NONE)
@ToString
public class AlignedFeatures {
@Id
private long alignedFeatureId;
Expand All @@ -61,6 +62,7 @@ public class AlignedFeatures {

protected double mergedIonMass;
protected RetentionTime mergedRT;
@ToString.Exclude
protected LongList correlationPairIds;

protected CompoundAnnotation topAnnotation;
Expand All @@ -77,6 +79,7 @@ public Optional<List<MSMSScan>> getMsms() {
}

@JsonIgnore
@ToString.Exclude
protected List<Feature> features;

public Optional<List<Feature>> getFeatures() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Compound {
@Id
private long compoundId;
Expand All @@ -48,17 +49,20 @@ public class Compound {
* Group of edges between pairs of feature alignments that correlate among each other. Connected components
* from the whole graph of correlated pairs (whole dataset)
*/
@ToString.Exclude
LongList correlatedIonPairIds; //todo denormalize instead?

//foreign fields
@JsonIgnore
@ToString.Exclude
List<AlignedFeatures> adductFeatures;

public Optional<List<AlignedFeatures>> getAdductFeatures() {
return Optional.ofNullable(adductFeatures);
}

@JsonIgnore
@ToString.Exclude
List<CorrelatedIonPair> correlatedIonPairs;

public Optional<List<CorrelatedIonPair>> getCorrelatedIonPairs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@
package de.unijena.bioinf.ms.persistence.model.core;

import jakarta.persistence.Id;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.*;
import org.jetbrains.annotations.NotNull;

/**
* Edge between two {@link AlignedFeatures}s
*/
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class CorrelatedIonPair {
enum Type {ADDUCT, INSOURCE, MULTIMERE, ISOMERE}
public enum Type {ADDUCT, INSOURCE, MULTIMERE, ISOMERE}

@Id
private long ionPairId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ToString
public class Feature {


Expand Down Expand Up @@ -63,6 +64,7 @@ public class Feature {
* Foreign Field by apexScanId
*/
@JsonIgnore
@ToString.Exclude
protected Scan apexScan;

public Optional<Scan> getApexScan() {
Expand All @@ -76,13 +78,15 @@ protected SimpleSpectrum getApexSpectrum() {
/**
* Extracted isotope pattern of this feature
*/
@ToString.Exclude
protected SimpleSpectrum isotopePattern; //artificial spectrum -> no scan

/**
* MS/MS spectra belonging to this feature, referenced by the feature id
* Foreign Field by featureId
*/
@JsonIgnore
@ToString.Exclude
protected List<MSMSScan> msms;

public Optional<List<MSMSScan>> getMsms() {
Expand All @@ -99,5 +103,6 @@ public Stream<MutableMs2Spectrum> getMSMSSpectra(){
* Traces of this feature (mono-isotopic + isotope peaks)
* Optional Field
*/
@ToString.Exclude
protected List<Trace> traces;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@
import de.unijena.bioinf.ChemistryBase.ms.IsolationWindow;
import de.unijena.bioinf.ChemistryBase.ms.utils.SimpleSpectrum;
import jakarta.persistence.Id;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.*;

/**
* A measured MS/MS Spectrum (usually MS2) with metadata.
*/
@Getter
@Setter
@NoArgsConstructor
@ToString(callSuper = true)
public class MSMSScan extends AbstractScan {
@Builder
public MSMSScan(long scanId, Long runId, String scanNumber, Double scanTime, Double ccs, SimpleSpectrum peaks, Long precursorScanId, byte msLevel, IsolationWindow isolationWindow, CollisionEnergy collisionEnergy, Double mzOfInterest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.Id;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Run {
//todo are there other types like validation or calibration???
enum Type {
public enum Type {
SAMPLE,
BLANK
}
Expand All @@ -57,7 +60,7 @@ enum Type {
private ChromatographyType chromatography;
private IonizationType ionization;
private FragmentationType fragmentation;
private MassAnalyzerType massAnalyzer;
private List<MassAnalyzerType> massAnalyzers;


/**
Expand All @@ -72,6 +75,7 @@ enum Type {
*/
@Nullable
@JsonIgnore
@ToString.Exclude
private SourceFile sourceFile;
//endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
@Getter
@Setter
@NoArgsConstructor
@ToString(callSuper = true)
public class Scan extends AbstractScan{
@Builder
public Scan(long scanId, Long runId, String scanNumber, Double scanTime, Double ccs, SimpleSpectrum peaks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
package de.unijena.bioinf.ms.persistence.model.core;

import jakarta.persistence.Id;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.*;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class SourceFile {
enum Format {
public enum Format {
//todo do we need more info here?
MZML("Open MzML format"), MZXML("Open MzXML format (Deprecated)"), OTHER("Unknown or unspecified format");

Expand Down Expand Up @@ -59,5 +60,6 @@ enum Format {
/**
* File contents stored as gzipped byte stream
*/
@ToString.Exclude
private byte[] data;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ToString(onlyExplicitlyIncluded = true)
public class Trace {
/**
* ID of the Run this trace belongs to
*/
@ToString.Include
long runId;

/**
* Ids of the scans this trace is build from
* should be sorted by RT
*/
@ToString.Include
LongList scanIds;

/**
Expand Down

0 comments on commit ed2cea9

Please sign in to comment.