Permalink
Browse files

Reworked Generators for DS selections.

* Switch Generator on SelectionChanged
* Contribute atoms to generators vis GeneratorParameter, not AtomContainer.Properties
* ITestResult contribute GeneratorParameters
* Added Visible and AtomMap parameter to Generators in DS
  • Loading branch information...
1 parent b24acd5 commit 7ca476259c49a11eaca99ca48371970e0c733d16 @olas committed Jun 30, 2010
Showing with 439 additions and 103 deletions.
  1. +9 −7 plugins/net.bioclipse.ds.bursi.signatures/src/net/bioclipse/ds/bursi/signatures/SignSIgRunner.java
  2. +0 −1 plugins/net.bioclipse.ds.common/src/net/bioclipse/ds/matcher/SmartsMatcher.java
  3. +1 −2 plugins/net.bioclipse.ds.cpdb.signatures/src/net/bioclipse/ds/cpdb/signatures/CPDBSignSigRunner.java
  4. +0 −8 plugins/net.bioclipse.ds.ui/plugin.xml
  5. +4 −1 plugins/net.bioclipse.ds.ui/src/net/bioclipse/ds/ui/ImageHelper.java
  6. +68 −2 plugins/net.bioclipse.ds.ui/src/net/bioclipse/ds/ui/views/DSView.java
  7. +5 −2 plugins/net.bioclipse.ds/META-INF/MANIFEST.MF
  8. +10 −0 plugins/net.bioclipse.ds/plugin.xml
  9. +1 −1 ...oclipse.ds.ui/src/net/bioclipse/ds/ui/prefs → net.bioclipse.ds/src/net/bioclipse/ds}/DSPrefs.java
  10. +8 −2 plugins/net.bioclipse.ds/src/net/bioclipse/ds/model/ITestResult.java
  11. +37 −0 plugins/net.bioclipse.ds/src/net/bioclipse/ds/model/result/AtomResultMatch.java
  12. +61 −23 ...lipse/ds/ui → net.bioclipse.ds/src/net/bioclipse/ds/model/result}/BlueRedColorScaleGenerator.java
  13. +18 −1 ...ui/src/net/bioclipse/ds/ui → net.bioclipse.ds/src/net/bioclipse/ds/model/result}/ColorHelper.java
  14. +1 −1 ...src/net/bioclipse/ds/ui → net.bioclipse.ds/src/net/bioclipse/ds/model/result}/DSResultHelper.java
  15. +4 −0 plugins/net.bioclipse.ds/src/net/bioclipse/ds/model/result/DoubleResult.java
  16. +143 −0 plugins/net.bioclipse.ds/src/net/bioclipse/ds/model/result/PosNegIncColorGenerator.java
  17. +27 −0 plugins/net.bioclipse.ds/src/net/bioclipse/ds/model/result/PosNegIncMatch.java
  18. +10 −42 plugins/net.bioclipse.ds/src/net/bioclipse/ds/model/result/ScaledResultMatch.java
  19. +27 −8 plugins/net.bioclipse.ds/src/net/bioclipse/ds/model/result/SimpleResult.java
  20. +2 −2 plugins/net.bioclipse.ds/src/net/bioclipse/ds/model/result/SmartsMatch.java
  21. +3 −0 plugins/net.bioclipse.ds/src/net/bioclipse/ds/model/result/SubStructureMatch.java
@@ -37,6 +37,7 @@
import net.bioclipse.ds.model.DSException;
import net.bioclipse.ds.model.IDSTest;
import net.bioclipse.ds.model.ITestResult;
+import net.bioclipse.ds.model.result.PosNegIncMatch;
import net.bioclipse.ds.model.result.ScaledResultMatch;
import net.bioclipse.ds.model.result.SubStructureMatch;
import net.bioclipse.ds.signatures.business.ISignaturesManager;
@@ -382,7 +383,7 @@ public String toString() {
//Create a new match with correct coloring
// SubStructureMatch match = new SubStructureMatch(significantSignature,ITestResult.INCONCLUSIVE);
- ScaledResultMatch match = new ScaledResultMatch(significantSignature,ITestResult.INCONCLUSIVE);
+ PosNegIncMatch match = new PosNegIncMatch(significantSignature,ITestResult.INCONCLUSIVE);
if (prediction>0)
match.setClassification( ITestResult.POSITIVE );
@@ -398,8 +399,9 @@ public String toString() {
//We should add atoms from the input cdkmol, not the clone!
// significantAtomsContainer.addAtom( cdkmol.getAtomContainer().getAtom( significantAtomNumber ));
logger.debug("center atom: " + significantAtom);
- //Set to max for scaledresult
- match.putAtomResult( significantAtomNumber, 100 );
+
+ //Set each atom to overall match classification
+ match.putAtomResult( significantAtomNumber, match.getClassification() );
//Also add all atoms connected to significant atoms to list
for (IAtom nbr : cdkmol.getAtomContainer().getConnectedAtomsList(cdkmol.getAtomContainer().getAtom( significantAtomNumber )) ){
@@ -408,17 +410,17 @@ public String toString() {
// significantAtomsContainer.addAtom(atomToAdd);
logger.debug("nbr atom: " + nbrAtomNr);
- //Set to max for scaledresult
- match.putAtomResult( nbrAtomNr, 100 );
+ //Set each atom to overall match classification
+ match.putAtomResult( nbrAtomNr, match.getClassification() );
}
}
logger.debug("Number of center atoms: " + significantAtoms.size());
//We want to set the color of the hilighting depending on the prediction. If the decision function > 0.0 the color should be red, otherwise it should be green.
//we also want the filled circles to be larger so that they become visible for non carbons.
// match.setAtomContainer( significantAtomsContainer );
- match.writeResultsAsProperties( cdkmol.getAtomContainer(),
- net.bioclipse.ds.bursi.signatures.Activator.BURSI_RESULT_PROPERTY);
+// match.writeResultsAsProperties( cdkmol.getAtomContainer(),
+// net.bioclipse.ds.bursi.signatures.Activator.BURSI_RESULT_PROPERTY);
//We can have multiple hits...
List<ITestResult> results=new ArrayList<ITestResult>();
@@ -252,7 +252,6 @@ private boolean isValidSmarts( String smarts ) {
match.putAtomResult( aindex, 100 );
}
match.setSmartsString( currentSmarts );
- match.writeResultsAsProperties( cdkmol.getAtomContainer(), "SMARTS");
results.add( match );
}
@@ -438,8 +438,7 @@ public String toString() {
//we also want the filled circles to be larger so that they become visible for non carbons.
// match.setAtomContainer( significantAtomsContainer );
- match.writeResultsAsProperties(cdkmol.getAtomContainer(),
- net.bioclipse.ds.cpdb.signatures.Activator.CPDB_RESULT_PROPERTY);
+// match.writeResultsAsProperties(cdkmol.getAtomContainer(), "BOGUS");
//We can have multiple hits...
List<ITestResult> results=new ArrayList<ITestResult>();
@@ -2,14 +2,6 @@
<?eclipse version="3.4"?>
<plugin>
-
-<extension
- point="net.bioclipse.cdk.jchempaint.generator">
- <generator
- class="net.bioclipse.ds.ui.BlueRedColorScaleGenerator">
- </generator>
- </extension>
-
<extension
point="org.eclipse.ui.views">
<category
@@ -17,6 +17,8 @@
import net.bioclipse.cdk.domain.ICDKMolecule;
import net.bioclipse.core.business.BioclipseException;
import net.bioclipse.ds.model.ITestResult;
+import net.bioclipse.ds.model.result.BlueRedColorScaleGenerator;
+import net.bioclipse.ds.model.result.PosNegIncColorGenerator;
import net.bioclipse.ds.model.result.SubStructureMatch;
import org.openscience.cdk.Molecule;
@@ -103,8 +105,9 @@
if (newMatch!=null){
BlueRedColorScaleGenerator generator=new BlueRedColorScaleGenerator();
-// generator.add( newMatch );
+ PosNegIncColorGenerator gen2=new PosNegIncColorGenerator();
generators.add(generator);
+ generators.add( gen2 );
}
generators.add(new BasicAtomGenerator());
@@ -20,6 +20,7 @@
import net.bioclipse.cdk.domain.CDKMolecule;
import net.bioclipse.cdk.domain.ICDKMolecule;
import net.bioclipse.cdk.jchempaint.editor.JChemPaintEditor;
+import net.bioclipse.cdk.jchempaint.view.ChoiceGenerator;
import net.bioclipse.cdk.ui.sdfeditor.editor.MultiPageMoleculesEditorPart;
import net.bioclipse.core.business.BioclipseException;
import net.bioclipse.core.util.LogUtils;
@@ -30,7 +31,12 @@
import net.bioclipse.ds.model.IDSTest;
import net.bioclipse.ds.model.ITestResult;
import net.bioclipse.ds.model.TestRun;
+import net.bioclipse.ds.model.result.AtomResultMatch;
+import net.bioclipse.ds.model.result.BlueRedColorScaleGenerator;
+import net.bioclipse.ds.model.result.PosNegIncColorGenerator;
+import net.bioclipse.ds.model.result.PosNegIncMatch;
import net.bioclipse.ds.model.result.SimpleResult;
+import net.bioclipse.ds.model.result.SubStructureMatch;
import net.bioclipse.ds.report.DSSingleReportModel;
import net.bioclipse.ds.report.StatusHelper;
import net.bioclipse.ds.ui.DSContextProvider;
@@ -70,6 +76,9 @@
import org.eclipse.swt.SWT;
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtomContainer;
+import org.openscience.cdk.renderer.RendererModel;
+import org.openscience.cdk.renderer.generators.IGenerator;
+import org.openscience.cdk.renderer.generators.IGeneratorParameter;
/**
*
@@ -204,13 +213,70 @@ public void createPartControl(Composite parent) {
public void selectionChanged( SelectionChangedEvent event ) {
updateActionStates();
+ turnOffAllExternalGenerators();
Object obj = ((IStructuredSelection)event.getSelection()).getFirstElement();
if ( obj instanceof ITestResult ) {
ITestResult tr = (ITestResult) obj;
- selectedProperty=tr.getResultProperty();
-
+
+ Class<? extends IGeneratorParameter<Boolean>> visibilityParam = tr.getGeneratorVisibility();
+ Class<? extends IGeneratorParameter<Map<Integer, Integer>>> atomMapParam = tr.getGeneratorAtomMap();
+
+ if (visibilityParam==null){
+ logger.debug("The selected TestResult does not provide a generatorVisibility.");
+ return;
+ }
+
+ JChemPaintEditor jcp=getJCPfromActiveEditor();
+ if (jcp==null) return;
+
+ RendererModel model = jcp.getWidget().getRenderer2DModel();
+
+ //And turn only the selected on
+ model.set(visibilityParam, true);
+ logger.debug("Turned on Generator: " + tr.getGeneratorVisibility());
+
+ if (atomMapParam!=null){
+ if (tr instanceof AtomResultMatch) {
+ AtomResultMatch atomResMatch = (AtomResultMatch) tr;
+ model.set(atomMapParam, atomResMatch.getResultMap());
+ logger.debug(" ...and AtomMapGeneratorParameter is used with content.");
+ }else{
+ logger.debug(" ...however, an AtomMapGeneratorParameter is available but TestResult is not PosNegIncMatch.");
+ }
+
+ }
+ else{
+ logger.debug(" ...however, no AtomMapGeneratorParameter is available.");
+ }
+
+
}
}
+
+ private void turnOffAllExternalGenerators() {
+ //Switch off all other DS-generators!
+ List<IGenerator<IAtomContainer>> generators = ChoiceGenerator.getGeneratorsFromExtension();
+ for(IGenerator generator: generators) {
+ List<IGeneratorParameter<?>> params = generator.getParameters();
+ if(params.isEmpty()) continue;
+ for (IGeneratorParameter param : params){
+ if (param instanceof BlueRedColorScaleGenerator.Visibility) {
+ BlueRedColorScaleGenerator.Visibility v = (BlueRedColorScaleGenerator.Visibility) param;
+ v.setValue(false);
+ logger.debug("Turned off Generator: " + generator);
+ }
+ if (param instanceof PosNegIncColorGenerator.Visibility) {
+ PosNegIncColorGenerator.Visibility v = (PosNegIncColorGenerator.Visibility) param;
+ v.setValue(false);
+ logger.debug("Turned off Generator: " + generator);
+ }
+// if (param instanceof IGeneratorParameter<Boolean>) {
+// IGeneratorParameter<Boolean> bp= (IGeneratorParameter<Boolean>)param;
+// model.set(bp, false);
+// }
+ }
+ }
+ }
});
@@ -13,9 +13,12 @@ Require-Bundle: org.eclipse.ui,
net.bioclipse.cdk.business,
net.bioclipse.cdk.jchempaint,
org.openscience.cdk.interfaces,
- org.openscience.cdk.nonotify
+ org.openscience.cdk.nonotify,
+ org.openscience.cdk.render;bundle-version="1.3.5",
+ org.openscience.cdk.renderbasic;bundle-version="1.3.5"
Bundle-ActivationPolicy: lazy
-Import-Package: org.apache.log4j
+Import-Package: javax.vecmath,
+ org.apache.log4j
Export-Package: net.bioclipse.ds,
net.bioclipse.ds.business,
net.bioclipse.ds.model,
@@ -12,4 +12,14 @@
</scriptContribution>
</extension>
+<extension
+ point="net.bioclipse.cdk.jchempaint.generator">
+ <generator
+ class="net.bioclipse.ds.model.result.BlueRedColorScaleGenerator">
+ </generator>
+ <generator
+ class="net.bioclipse.ds.model.result.PosNegIncColorGenerator">
+ </generator>
+ </extension>
+
</plugin>
@@ -1,4 +1,4 @@
-package net.bioclipse.ds.ui.prefs;
+package net.bioclipse.ds;
/**
*
@@ -10,8 +10,12 @@
******************************************************************************/
package net.bioclipse.ds.model;
+import java.util.Map;
+
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.swt.graphics.Image;
+import org.openscience.cdk.renderer.generators.IGenerator;
+import org.openscience.cdk.renderer.generators.IGeneratorParameter;
import net.bioclipse.cdk.domain.ISubStructure;
@@ -57,8 +61,10 @@
String getSuffix();
- public String getResultProperty();
- public void setResultProperty( String propertyKey );
+// public String getResultProperty();
+// public void setResultProperty( String propertyKey );
+ public Class<? extends IGeneratorParameter<Boolean>> getGeneratorVisibility();
+ public Class<? extends IGeneratorParameter<Map<Integer, Integer>>> getGeneratorAtomMap();
}
@@ -0,0 +1,37 @@
+package net.bioclipse.ds.model.result;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * @author ola
+ */
+public class AtomResultMatch extends SubStructureMatch{
+
+ //AtomNumber > Value
+ private Map<Integer, Integer> resultMap;
+
+ public AtomResultMatch(String name, int resultStatus) {
+ super( name, resultStatus );
+ resultMap=new HashMap<Integer, Integer>();
+ }
+
+ public void setResultMap( Map<Integer, Integer> resulMap ) {
+ this.resultMap = resulMap;
+ }
+
+ public Map<Integer, Integer> getResultMap() {
+ return resultMap;
+ }
+
+ public void putAtomResult( Integer atomToAdd, Integer result ) {
+ if (resultMap==null) resultMap=new HashMap<Integer, Integer>();
+ resultMap.put( atomToAdd, result );
+ if (!getAtomNumbers().contains( atomToAdd )){
+ getAtomNumbers().add( atomToAdd );
+ }
+
+ }
+
+}
Oops, something went wrong.

0 comments on commit 7ca4762

Please sign in to comment.