Skip to content

Commit

Permalink
Merge branch 'main' of github.com:lifs-tools/jgoslin
Browse files Browse the repository at this point in the history
  • Loading branch information
nilshoffmann committed Oct 20, 2023
2 parents 974bfc9 + 7890743 commit 0510164
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class FattyAcid extends FunctionalGroup {
public static final Set<LipidFaBondType> LCB_STATES = new HashSet<>(Arrays.asList(LipidFaBondType.LCB_REGULAR, LipidFaBondType.LCB_EXCEPTION));
protected int numCarbon;
protected LipidFaBondType lipidFaBondType;
public boolean unresolvedHiddenFa = false;

public FattyAcid(String _name, KnownFunctionalGroups knownFunctionalGroups) {
this(_name, 0, null, null, LipidFaBondType.ESTER, 0, knownFunctionalGroups);
Expand Down Expand Up @@ -275,6 +276,12 @@ public ElementTable getFunctionalGroupElements() {
@Override
public void computeElements() {
elements = new ElementTable();

if (unresolvedHiddenFa){
elements.put(Element.O, 1);
elements.put(Element.H, -1);
return;
}

int num_double_bonds = doubleBonds.getNumDoubleBonds();
if (lipidFaBondType == LipidFaBondType.ETHER_PLASMENYL) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ public LipidMolecularSpecies(Headgroup _headgroup, Collection<FattyAcid> _fa, Kn

// add 0:0 dummys
for (int i = _fa.size(); i < info.totalFa; ++i) {
FattyAcid fatty_acid = new FattyAcid("FA" + Integer.toString(i + 1), knownFunctionalGroups);
fatty_acid.position = -1;
info.add(fatty_acid);
fa.put(fatty_acid.getName(), fatty_acid);
faList.add(fatty_acid);
FattyAcid fattyAcid = new FattyAcid("FA" + Integer.toString(i + 1), knownFunctionalGroups);
fattyAcid.position = -1;
fattyAcid.unresolvedHiddenFa = (1 < _fa.size() && _fa.size() < info.possFa);
info.add(fattyAcid);
fa.put(fattyAcid.getName(), fattyAcid);
faList.add(fattyAcid);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public final class LipidSpeciesInfo extends FattyAcid {
private LipidLevel level;
public int numEthers;
public int numSpecifiedFa;
public int possFa;
public int totalFa;
public LipidFaBondType extendedClass;
public static final String[] ETHER_PREFIX = {"", "O-", "dO-", "tO-", "eO-"};
Expand All @@ -47,6 +48,7 @@ public LipidSpeciesInfo(int _lipid_class, KnownFunctionalGroups knownFunctionalG
numSpecifiedFa = 0;
extendedClass = LipidFaBondType.ESTER;
totalFa = (LipidClasses.getInstance().size() > lipidClass) ? LipidClasses.getInstance().get(lipidClass).maxNumFa : 0;
possFa = (LipidClasses.getInstance().size() > lipidClass) ? LipidClasses.getInstance().get(lipidClass).possibleNumFa : 0;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,13 @@ protected boolean check_full_structure(FunctionalGroup obj){
}
return full;
}



protected Headgroup prepareHeadgroupAndChecks() {
return prepareHeadgroupAndChecks(true);
}

protected Headgroup prepareHeadgroupAndChecks(boolean allowClassShift) {
Headgroup headgroup = new Headgroup(headGroup, headgroupDecorators, useHeadGroup);
if (useHeadGroup) {
return headgroup;
Expand All @@ -118,21 +123,23 @@ protected Headgroup prepareHeadgroupAndChecks() {
}
int poss_fa = (LipidClasses.getInstance().size() > headgroup.getLipidClass()) ? LipidClasses.getInstance().get(headgroup.getLipidClass()).possibleNumFa : 0;

// make lyso
boolean can_be_lyso = (LipidClasses.getInstance().size() > Headgroup.getClass("L" + headGroup)) ? LipidClasses.getInstance().get(Headgroup.getClass("L" + headGroup)).specialCases.contains("Lyso") : false;
LipidClassMeta l = LipidClasses.getInstance().get(Headgroup.getClass("LCL"));
if ((true_fa + 1 == poss_fa || true_fa + 2 == poss_fa) && level != LipidLevel.SPECIES && headgroup.getLipidCategory() == LipidCategory.GP && can_be_lyso) {
if (true_fa + 1 == poss_fa) headGroup = "L" + headGroup;
else headGroup = "DL" + headGroup;
headgroup = new Headgroup(headGroup, headgroupDecorators, useHeadGroup);
poss_fa = (LipidClasses.getInstance().size() > headgroup.getLipidClass()) ? LipidClasses.getInstance().get(headgroup.getLipidClass()).possibleNumFa : 0;
}

else if ((true_fa + 1 == poss_fa || true_fa + 2 == poss_fa) && level != LipidLevel.SPECIES && headgroup.getLipidCategory() == LipidCategory.GL && headGroup.equals("TG")) {
if (true_fa + 1 == poss_fa) headGroup = "DG";
else headGroup = "MG";
headgroup = new Headgroup(headGroup, headgroupDecorators, useHeadGroup);
poss_fa = (LipidClasses.getInstance().size() > headgroup.getLipidClass()) ? LipidClasses.getInstance().get(headgroup.getLipidClass()).possibleNumFa : 0;
if (allowClassShift){
// make lyso
boolean can_be_lyso = (LipidClasses.getInstance().size() > Headgroup.getClass("L" + headGroup)) ? LipidClasses.getInstance().get(Headgroup.getClass("L" + headGroup)).specialCases.contains("Lyso") : false;
LipidClassMeta l = LipidClasses.getInstance().get(Headgroup.getClass("LCL"));
if ((true_fa + 1 == poss_fa || true_fa + 2 == poss_fa) && level != LipidLevel.SPECIES && headgroup.getLipidCategory() == LipidCategory.GP && can_be_lyso) {
if (true_fa + 1 == poss_fa) headGroup = "L" + headGroup;
else headGroup = "DL" + headGroup;
headgroup = new Headgroup(headGroup, headgroupDecorators, useHeadGroup);
poss_fa = (LipidClasses.getInstance().size() > headgroup.getLipidClass()) ? LipidClasses.getInstance().get(headgroup.getLipidClass()).possibleNumFa : 0;
}

else if ((true_fa + 1 == poss_fa || true_fa + 2 == poss_fa) && level != LipidLevel.SPECIES && headgroup.getLipidCategory() == LipidCategory.GL && headGroup.equals("TG")) {
if (true_fa + 1 == poss_fa) headGroup = "DG";
else headGroup = "MG";
headgroup = new Headgroup(headGroup, headgroupDecorators, useHeadGroup);
poss_fa = (LipidClasses.getInstance().size() > headgroup.getLipidClass()) ? LipidClasses.getInstance().get(headgroup.getLipidClass()).possibleNumFa : 0;
}
}

// check if all functional groups have a position to be full structure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private void buildLipid(TreeNode node) {
if (acerSpecies) {
faList.get(0).setNumCarbon(faList.get(0).getNumCarbon() - 2);
}
Headgroup headgroup = prepareHeadgroupAndChecks();
Headgroup headgroup = prepareHeadgroupAndChecks(false);

// add count numbers for fatty acyl chains
int fa_it = (faList.size() > 0 && (faList.get(0).getLipidFaBondType() == LipidFaBondType.LCB_EXCEPTION || faList.get(0).getLipidFaBondType() == LipidFaBondType.LCB_REGULAR)) ? 1 : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ public void testShorthandParserTest() {

l = parser.parse("LHexCer(1) 18:1(5E);3OH/0:0", handler);
assertEquals("LHexCer(1) 18:1(5E);3OH", l.getLipidString());

l = parser.parse("TG 18:0_42:2", handler);
assertEquals("TG 18:0_42:2", l.getLipidString());


l = parser.parse("Gal-Glc-Cer(1) 17:1(5E);15Me[R];3OH[R],4OH[S]/22:0;2OH[R]", handler);
Expand Down

0 comments on commit 0510164

Please sign in to comment.