Skip to content

Commit

Permalink
better handling for SP without explicit OH description
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik-kopczynski committed Jun 10, 2022
1 parent a388642 commit b52123a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@
* @author Nils Hoffmann
*/
public class FattyAcid extends FunctionalGroup {


public static final Set<String> fgExceptions = new HashSet<>(Arrays.asList("acyl", "alkyl", "cy", "cc", "acetoxy"));
public static final Set<LipidFaBondType> LCB_STATES = new HashSet<>(Arrays.asList(LipidFaBondType.LCB_REGULAR, LipidFaBondType.LCB_EXCEPTION));
protected int numCarbon;
protected LipidFaBondType lipidFaBondType;
private final Set<String> fgExceptions = new HashSet<>(Arrays.asList("acyl", "alkyl", "cy", "cc", "acetoxy"));


public FattyAcid(String _name, KnownFunctionalGroups knownFunctionalGroups) {
this(_name, 0, null, null, LipidFaBondType.ESTER, 0, knownFunctionalGroups);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public ShorthandParserEventHandler(KnownFunctionalGroups knownFunctionalGroups)
entry("carbohydrate_structural_pre_event", this::setCarbohydrateStructural),
entry("carbohydrate_isomeric_pre_event", this::setCarbohydrateIsomeric),
// fatty acyl events
entry("lcb_post_event", this::setLcb),
entry("lcb_pre_event", this::newLcb),
entry("lcb_post_event", this::addFattyAcylChain),
entry("fatty_acyl_chain_pre_event", this::newFattyAcylChain),
entry("fatty_acyl_chain_post_event", this::addFattyAcylChain),
entry("carbon_pre_event", this::setCarbon),
Expand All @@ -128,6 +129,7 @@ public ShorthandParserEventHandler(KnownFunctionalGroups knownFunctionalGroups)
entry("func_group_count_pre_event", this::setFunctionalGroupCount),
entry("stereo_type_fg_pre_event", this::setFunctionalGroupStereo),
entry("molecular_func_group_name_pre_event", this::setSnPositionFuncGroup),
entry("fa_db_only_post_event", this::addDiHydroxyl),
// set cycle events
entry("func_group_cycle_pre_event", this::setCycle),
entry("func_group_cycle_post_event", this::addCycle),
Expand Down Expand Up @@ -323,10 +325,10 @@ private void setCarbohydrateIsomeric(TreeNode node) {
tmp.put("func_group_head", 1);
}

private void setLcb(TreeNode node) {
FattyAcid fa = faList.get(faList.size() - 1);
fa.setName("LCB");
fa.setType(LipidFaBondType.LCB_REGULAR);
private void newLcb(TreeNode node) {
newFattyAcylChain(node);
currentFas.getLast().setName("LCB");
((FattyAcid)currentFas.getLast()).setType(LipidFaBondType.LCB_REGULAR);
}

private void newFattyAcylChain(TreeNode node) {
Expand Down Expand Up @@ -422,6 +424,24 @@ private void setFunctionalGroup(TreeNode node) {
gd.put("fg_ring_stereo", "");
}


private void addDiHydroxyl(TreeNode node) {
if (!FattyAcid.LCB_STATES.contains(((FattyAcid)currentFas.getLast()).getLipidFaBondType())) return;
int num_h = 1;

if (FattyAcid.fgExceptions.contains(headGroup) && !headgroupDecorators.isEmpty()) {
num_h -= 1;
}

FunctionalGroup functional_group = knownFunctionalGroups.get("OH");
functional_group.setCount(num_h);
if (!currentFa.getFunctionalGroupsInternal().containsKey("OH")) {
currentFa.getFunctionalGroupsInternal().put("OH", new ArrayList<>());
}
currentFa.getFunctionalGroupsInternal().get("OH").add(functional_group);
}


private void addFunctionalGroup(TreeNode node) {
Dictionary gd = (Dictionary) tmp.get(faI());
String fg_name = (String) gd.get("fg_name");
Expand Down

0 comments on commit b52123a

Please sign in to comment.