-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: sync webcomponent props with attributes #234
Conversation
feels wrong to put them in this repository Refs: #229 (comment)
This reverts commit 5d1f3ff.
This reverts commit fa5594c.
5ca2ea0
to
ef716cc
Compare
keep some changes This reverts commit 1f4f81b
The only modification I kept from original PR with copy-paste handling is to prevent to propagate events It will avoid to display errors in console (copy is not working outside a valid user-interaction in browser, at least for firefox). |
@artaius do you think it will work for you? |
Thanks for the changes. As far as I can say this looks good to me. The only missing thing I can see is, that the molecule coordinates are not yet considered on changes nor are they accessible by properties/attributes. If this is supported as well, we can start to deploy a first prototype to our users. The coords are crucial as people wont accept if the display of the molecules change upon pasting. Otherwise I found the solutions to
|
I think we can use the |
For encoding reactions including mapping, coordinates, etc, you use the ReactionEncoder |
Fully agree, lets keep this concatination of "idcode coords" for molecules. This way we also get change events on coord changes, what makes sense. For reactions I think we can use the similar thing (as @thsa suggested). I think the following two methods should do. @thsa Can you please confirm that this makes sense for the editor (especially the mode param)? // get reaction idcode
String reactionIdCode = ReactionEncoder.encode(new Reaction(), true, ReactionEncoder.INCLUDE_MAPPING | ReactionEncoder.INCLUDE_COORDS | ReactionEncoder.INCLUDE_DRAWING_OBJECTS | ReactionEncoder.INCLUDE_CATALYSTS | ReactionEncoder.RETAIN_REACTANT_AND_PRODUCT_ORDER);
// parse reaction idcode
Reaction decodedReaction = ReactionEncoder.decode(reactionIdCode, true); |
It depends a little on the purpose. A typical case would be an encoding of a reaction with atom coords, mapping and original order of the reactants: If catalysts structures are needed, the a typical UI would probably not allow drawing them within the reaction editor, but do it in a separate step. If you need a canonical reaction representation, e.g. to remove duplicates from a database, then you would not include coords, mapping, catalysts. And you would allow the encoder to put reactants into a canonical order. |
It block other events like copy/paste
Deploying openchemlib-js with Cloudflare Pages
|
@thsa Thanks for the comments. I would then go with @thsa proposal, i.e. // get reaction idcode
String reactionIdCode = ReactionEncoder.encode(new Reaction(), true, ReactionEncoder.INCLUDE_MAPPING | ReactionEncoder.INCLUDE_COORDS | ReactionEncoder.RETAIN_REACTANT_AND_PRODUCT_ORDER);
// parse reaction idcode
Reaction decodedReaction = ReactionEncoder.decode(reactionIdCode, true); |
I can use And
|
For testing and comparison to the Java version you could download openmolecules.org/idcodeexplorer.jar. It is an editor that has molecule and reaction modes, both for molecules and substructures. On the fly it creates idcodes/rxncodes with every editor change. You can also paste an idcode or rxncode and it converts it to the respective structures/reactions... |
@tpoisseau Looks like if not all overloads of
|
2477a7c
to
b5fe462
Compare
@artaius Where could I find
webcomponent transform it to
Which look similar. |
This is just a minor change of the coordinates. Not sure where this comes from. @thsa might this come from some floating point inaccuracy, or because of the different drawing area sizes. @thsa Could you please give a hint about where to find the source code of the idcodeexplorer? |
@tpoisseau Do you have any plans to release a (beta) version of the current code to npm? This would be great as I could then already adapt the Vaadin project to the new package and test it as well. |
@targos reminds idcode could contains special chars not valid in DOM
As soon this PR is merged, we can release I guess, I'm not sure a beta is needed. Changes concern mainly the webcomponent, and add options to ReactionEncoder encode-decode. @artaius can you check the defaults params for ReactionEncoder to confirm the transition will be smooth please ? |
This reverts commit a1c8d94.
the source code of idcodeexplorer is not public, because it is meant as a test application for myself. |
the encoding part of the idcodeexplorer source is: if (mComboBoxMode.getSelectedIndex() == MODE_REACTION) {
Reaction rxn = mDrawPanel.getDrawArea().getReaction();
mTextFieldIDCode.setText(ReactionEncoder.encode(rxn, false,
ReactionEncoder.INCLUDE_DEFAULT | ReactionEncoder.RETAIN_REACTANT_AND_PRODUCT_ORDER));
mTextFieldSmiles.setText(!rxn.isFragment() ?
IsomericSmilesCreator.createReactionSmiles(rxn)
: IsomericSmilesCreator.createReactionSmarts(rxn));
}
else {
StereoMolecule mol = new StereoMolecule(mMolecule);
MoleculeStandardizer.standardize(mol,0);
Canonizer canonizer = new Canonizer(mol, Canonizer.ENCODE_ATOM_CUSTOM_LABELS);
mTextFieldIDCode.setText(canonizer.getIDCode() + " " + canonizer.getEncodedCoordinates());
mTextFieldSmiles.setText(mMolecule.isFragment() ?
IsomericSmilesCreator.createSmarts(mMolecule)
: IsomericSmilesCreator.createSmiles(mMolecule));
}
} |
ok, so you encode without absolute coordinates, So I guess it's normal import idcode from idcodeexplorer do not places the reactants exactly to same place when decode with |
@tpoisseau As far as I can say this looks good to me... 👍 And I agree, we don't need a beta. |
@tpoisseau Can you prepare a squash commit message and I'll merge? |
|
I just changed it to this for release-please:
|
Refs: #229
Refs: #231
New PR, without copy-paste events handlings
Reminder: sync webcomponent properties with attributes, and propagate vaadin events (need more discussions)