001/*
002 * 
003 */
004package de.isas.lipidomics.domain;
005
006import de.isas.lipidomics.palinom.exceptions.ConstraintViolationException;
007import java.util.Arrays;
008import java.util.List;
009import java.util.stream.Collectors;
010
011/**
012 * The lipid category nomenclature follows the shorthand notation of
013 * <pre>Liebisch, G., Vizcaíno,
014 * J.A., Köfeler, H., Trötzmüller, M., Griffiths, W.J., Schmitz, G., Spener, F.,
015 * and Wakelam, M.J.O. (2013). Shorthand notation for lipid structures derived
016 * from mass spectrometry. J. Lipid Res. 54, 1523–1530.</pre>
017 *
018 * We use the associations to either LipidMAPS or SwissLipids (Saccharolipids),
019 * where appropriate.
020 * 
021 * Example: Category=Glyerophospholipids (GP)
022 *
023 * @author nils.hoffmann
024 */
025public enum LipidCategory {
026
027    UNDEFINED("Undefined lipid category"),
028    /* SLM:000117142 Glycerolipids */
029    GL("Glycerolipids"),
030    /* SLM:000001193 Glycerophospholipids */
031    GP("Glycerophospholipids"),
032    /* SLM:000000525 Sphingolipids */
033    SP("Sphingolipids"),
034    /* SLM:000500463 Steroids and derivatives */
035    ST("Sterollipids"),
036    /* SLM:000390054 Fatty acyls and derivatives */
037    FA("Fattyacyls"),
038    /* LipidMAPS [SL]*/
039    SL("Saccharolipids"),
040    /* LipidMAPS [PK]*/
041    PK("Polyketides");
042
043    private final String fullName;
044
045    private LipidCategory(String fullName) {
046        this.fullName = fullName;
047    }
048
049    public String getFullName() {
050        return this.fullName;
051    }
052
053    public static LipidCategory forFullName(String fullName) {
054        List<LipidCategory> matches = Arrays.asList(LipidCategory.values()).stream().filter((t) -> {
055            return t.getFullName().equalsIgnoreCase(fullName);
056        }).collect(Collectors.toList());
057        if (matches.isEmpty()) {
058            return LipidCategory.UNDEFINED;
059        } else if (matches.size() > 1) {
060            throw new ConstraintViolationException("Query string " + fullName + " found more than once in enum values! Please check enum definition: fullName is compared case insensitive!");
061        }
062        return matches.get(0);
063    }
064}