Skip to content

Commit

Permalink
fixed a bug in retention of non-fragmentable molecules; applied code …
Browse files Browse the repository at this point in the history
…improvements;
  • Loading branch information
Mila1004 committed Nov 19, 2024
1 parent 9a58324 commit fd1df0e
Showing 1 changed file with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ public SimpleIDisplayEnumConstantProperty fragmentSaturationSettingProperty() {
//</editor-fold>
//
//<editor-fold desc="Public Properties Set">

@Override
public void setFragmentSaturationSetting(FragmentSaturationOption anOption) throws NullPointerException {
Objects.requireNonNull(anOption, "Given saturation option is null.");
Expand Down Expand Up @@ -471,10 +472,12 @@ public void setSeparateTertQuatCarbonFromRingSetting(boolean aBoolean) {
//</editor-fold>
//
//<editor-fold desc="Public Methods">

@Override
public IMoleculeFragmenter copy() {
AlkylStructureFragmenter tmpCopy = new AlkylStructureFragmenter();
tmpCopy.setFragmentSaturationSetting((IMoleculeFragmenter.FragmentSaturationOption) this.fragmentSaturationSetting.get());
tmpCopy.setKeepNonFragmentableMoleculesSetting(this.keepNonFragmentableMoleculesSetting.get());
tmpCopy.setFragmentSideChainsSetting(this.fragmentSideChainsSetting.get());
tmpCopy.setMaxChainLengthSetting(this.maxChainLengthSetting.get());
tmpCopy.setAltHandlingTertQuatCarbonsSetting(this.altHandlingSingleTertQuatCarbonsSetting.get());
Expand Down Expand Up @@ -525,6 +528,7 @@ public boolean shouldBeFiltered(IAtomContainer aMolecule) {
case IElement.C -> tmpCarbonCount++;
default -> {
if (this.keepNonFragmentableMoleculesSetting.get()) {
System.out.println("filter + posSetting");
aMolecule.setProperty("ASF.FilterMarker", true);
return false;
}
Expand Down Expand Up @@ -566,8 +570,8 @@ public boolean shouldBePreprocessed(IAtomContainer aMolecule) throws NullPointer
public boolean canBeFragmented(IAtomContainer aMolecule) throws NullPointerException {
//throws NullpointerException if molecule is null
Objects.requireNonNull(aMolecule, "Given molecule is null.");
System.out.println("canBeFragmented");
if (aMolecule.getProperty("ASF.FilterMarker")) {
System.out.println("if canBeFrag");
return true;
}
boolean tmpShouldBeFiltered = this.shouldBeFiltered(aMolecule);
Expand All @@ -590,6 +594,7 @@ public IAtomContainer applyPreprocessing(IAtomContainer aMolecule) throws NullPo
//</editor-fold>
//
//<editor-fold desc="Fragmentation">

@Override
public List<IAtomContainer> fragmentMolecule(IAtomContainer aMolecule)
throws NullPointerException, IllegalArgumentException, CloneNotSupportedException {
Expand All @@ -607,8 +612,7 @@ public List<IAtomContainer> fragmentMolecule(IAtomContainer aMolecule)
tmpPreFragmentationAtomCount++;
}
}
System.out.println("PreFragAtomCount: " + tmpPreFragmentationAtomCount);
//System.out.println("PreFragBondCount: " + tmpClone.getBondCount());
AlkylStructureFragmenter.this.logger.log(Level.INFO, "PreFragAtomCount: " + tmpPreFragmentationAtomCount);
//move percieveAtomType to preprocessing
try {
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(tmpClone);
Expand Down Expand Up @@ -641,7 +645,7 @@ public List<IAtomContainer> fragmentMolecule(IAtomContainer aMolecule)
tmpPostFragmentationAtomCount++;
}
}
System.out.println("PostFragAtomCount: " + tmpPostFragmentationAtomCount);
AlkylStructureFragmenter.this.logger.log(Level.INFO, "PostFragAtomCount: " + tmpPostFragmentationAtomCount);
if (tmpPostFragmentationAtomCount != tmpPreFragmentationAtomCount && !this.ASFDebugBoolean) {
throw new Exception("Molecular formula is not the same between original molecule and received fragments!");
}
Expand Down Expand Up @@ -704,7 +708,12 @@ protected IAtom[] fillAtomArray(IAtomContainer aClone) {
tmpAtomArray[tmpAlkylSFAtomIndex] = tmpAtom;
}
}
return tmpAtomArray;
ArrayList<IAtom> tmpRemovedNull = new ArrayList<IAtom>();
for (IAtom tmpAtom: tmpAtomArray)
if (tmpAtom != null)
tmpRemovedNull.add(tmpAtom);
return tmpRemovedNull.toArray(new IAtom[0]);
//return tmpAtomArray;
}
/**
* Method to fill an IBond array with the bonds of the input IAtomContainer
Expand Down Expand Up @@ -1085,12 +1094,11 @@ else if (tmpAtom.getProperty(AlkylStructureFragmenter.INTERNAL_ASF_DOUBLE_BOND_M
boolean tmpEnd = tmpDoubleToRingBond.getEnd().getProperty(AlkylStructureFragmenter.INTERNAL_ASF_RING_MARKER_KEY);
if (tmpBegin || tmpEnd) {
tmpRingFragmentationContainer.addAtom(tmpAtom);
System.out.println("double bond to ring atom added");
//System.out.println("double bond to ring atom added");
} else {
tmpIsolatedMultiBondsContainer.addAtom(tmpAtom);
System.out.println("double bond atom added");
//System.out.println("double bond atom added");
}
//if (tmpAtom.getBond(tmpArrayAtom).)
}
}
} else if (tmpAtom.getProperty(AlkylStructureFragmenter.INTERNAL_ASF_TRIPLE_BOND_MARKER_KEY)) {
Expand Down Expand Up @@ -1165,10 +1173,10 @@ else if (tmpAtom.getProperty(AlkylStructureFragmenter.INTERNAL_ASF_NEIGHBOR_MARK
boolean tmpEnd = tmpBond.getEnd().getProperty(AlkylStructureFragmenter.INTERNAL_ASF_RING_MARKER_KEY);
if (tmpBegin || tmpEnd) {
tmpRingFragmentationContainer.addBond(tmpBond);
System.out.println("double bond to ring added");
//System.out.println("double bond to ring added");
} else {
tmpIsolatedMultiBondsContainer.addBond(tmpBond);
System.out.println("double bond added");
//System.out.println("double bond added");
}
}
else if (tmpBond.getProperty(AlkylStructureFragmenter.INTERNAL_ASF_TRIPLE_BOND_MARKER_KEY)) {
Expand Down

0 comments on commit fd1df0e

Please sign in to comment.