-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add method Molecule.getAtomQueryFeaturesObject
* wip: add getAtomQueryFeaturesObject * create PlainJSObject class * feat: add method Molecule.getAtomQueryFeaturesObject --------- Co-authored-by: Michaël Zasso <targos@protonmail.com>
- Loading branch information
Showing
6 changed files
with
177 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
const { Molecule } = require('../minimal'); | ||
|
||
test('queryFeatures more than 2 neighbours', () => { | ||
const molecule = Molecule.fromIDCode('eF@Hp[qp'); | ||
|
||
const firstQueryFeatures = molecule.getAtomQueryFeaturesObject(0); | ||
expect(firstQueryFeatures.not0Neighbours).toBe(true); | ||
expect(firstQueryFeatures.not1Neighbours).toBe(true); | ||
expect(firstQueryFeatures.not2Neighbours).toBe(true); | ||
expect(firstQueryFeatures.not3Neighbours).toBe(false); | ||
|
||
}); | ||
|
||
test('queryFeatures exactly 2 hydrogens', () => { | ||
const molecule = Molecule.fromIDCode('eF@Hp_Qh'); | ||
const firstQueryFeatures = molecule.getAtomQueryFeaturesObject(0); | ||
expect(firstQueryFeatures.not0Hydrogen).toBe(true); | ||
expect(firstQueryFeatures.not1Hydrogen).toBe(true); | ||
expect(firstQueryFeatures.not2Hydrogen).toBe(false); | ||
expect(firstQueryFeatures.not3Hydrogen).toBe(true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/com/actelion/research/gwt/minimal/MoleculeQueryFeatures.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.actelion.research.gwt.minimal; | ||
|
||
import com.actelion.research.chem.StereoMolecule; | ||
import com.actelion.research.chem.Molecule; | ||
import com.google.gwt.core.client.JavaScriptObject; | ||
|
||
class MoleculeQueryFeatures { | ||
public static JavaScriptObject getAtomQueryFeatures(StereoMolecule oclMolecule, int atom) { | ||
PlainJSObject moleculeQueryFeatures = PlainJSObject.create(); | ||
|
||
moleculeQueryFeatures.setPropertyBoolean("aromatic", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFAromatic) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("notAromatic", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNotAromatic) > 0); | ||
|
||
moleculeQueryFeatures.setPropertyBoolean("notChain", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNotChain) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("not2RingBonds", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNot2RingBonds) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("not3RingBonds", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNot3RingBonds) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("not4RingBonds", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNot4RingBonds) > 0); | ||
|
||
moleculeQueryFeatures.setPropertyBoolean("noMoreNeighbours", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNoMoreNeighbours) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("moreNeighbours", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFMoreNeighbours) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("matchStereo", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFMatchStereo) > 0); | ||
|
||
moleculeQueryFeatures.setPropertyBoolean("not0PiElectrons", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNot0PiElectrons) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("not1PiElectrons", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNot1PiElectron) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("not2PiElectrons", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNot2PiElectrons) > 0); | ||
|
||
moleculeQueryFeatures.setPropertyBoolean("not0Hydrogen", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNot0Hydrogen) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("not1Hydrogen", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNot1Hydrogen) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("not2Hydrogen", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNot2Hydrogen) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("not3Hydrogen", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNot3Hydrogen) > 0); | ||
|
||
moleculeQueryFeatures.setPropertyBoolean("not0Neighbours", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNot0Neighbours) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("not1Neighbours", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNot0Neighbours) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("not2Neighbours", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNot2Neighbours) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("not3Neighbours", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNot3Neighbours) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("not4Neighbours", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNot4Neighbours) > 0); | ||
|
||
moleculeQueryFeatures.setPropertyBoolean("notChargeNeg", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNotChargeNeg) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("notCharge0", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNotCharge0) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("noChargePos", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFNotChargePos) > 0); | ||
|
||
moleculeQueryFeatures.setPropertyBoolean("ringSize0", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFRingSize0) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("ringSize3", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFRingSize3) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("ringSize4", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFRingSize4) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("ringSize5", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFRingSize5) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("ringSize6", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFRingSize6) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("ringSize7", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFRingSize7) > 0); | ||
moleculeQueryFeatures.setPropertyBoolean("ringSizeLarge", | ||
(oclMolecule.getAtomQueryFeatures(atom) & Molecule.cAtomQFRingSizeLarge) > 0); | ||
|
||
return moleculeQueryFeatures; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.actelion.research.gwt.minimal; | ||
|
||
import com.google.gwt.core.client.JavaScriptObject; | ||
|
||
public class PlainJSObject extends JavaScriptObject { | ||
protected PlainJSObject() {} | ||
|
||
public static PlainJSObject create() { | ||
return (PlainJSObject) JavaScriptObject.createObject().cast(); | ||
} | ||
|
||
public native final void setPropertyString(String key, String value)/*-{ | ||
this[key] = value; | ||
}-*/; | ||
|
||
public native final void setPropertyInt(String key, int value)/*-{ | ||
this[key] = value; | ||
}-*/; | ||
|
||
public native final void setPropertyBoolean(String key, boolean value)/*-{ | ||
this[key] = value; | ||
}-*/; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters