use of com.actelion.research.chem.reaction.Reaction in project openchemlib by Actelion.
the class Model method cleanReaction.
/*
public void resizeReaction(Dimension os, Dimension ns)
{
Reaction rxn = getReaction(false);
double offsetx = ns.getWidth() - os.getWidth();
double offsety = ns.getHeight() - os.getHeight();
double scale;
if (Math.abs(offsetx) > Math.abs(offsety)) {
scale = ns.getHeight() / os.getHeight();
} else {
scale = ns.getWidth() / os.getWidth();
}
ChemistryHelper.transformReaction(rxn, offsetx, offsety, scale);
setValue(rxn);
}
*/
public void cleanReaction(boolean cleanAll) {
Reaction reaction = getReaction();
// System.out.printf("cleanreaction %s\n",reaction.getReactants());
Dimension dim = getDisplaySize();
double w = dim.getWidth();
double h = dim.getHeight();
double width = w / 5;
if (w > 0 && h > 0) {
// new Arrow(mx , my, dx,20);
IDrawingObject arrow = getDrawingObjects().get(0);
arrow.setRect((float) (0.5f * w), (float) (0.5f * h), (float) (0.5f * .16 * w), 20);
arrowPos = new Point2D.Double((0.5f * w), (0.5f * h));
mMode = MODE_MULTIPLE_FRAGMENTS;
if (cleanAll)
cleanupCoordinates(true, true);
ChemistryHelper.scaleInto(reaction, 0, 0, dim.getWidth(), dim.getHeight(), width);
setValue(reaction);
}
}
use of com.actelion.research.chem.reaction.Reaction in project openchemlib by Actelion.
the class JDrawArea method tryAutoMapReaction.
private void tryAutoMapReaction() {
if (mMapper == null) {
new MoleculeAutoMapper(mMol).autoMap();
return;
}
SSSearcher sss = new MySSSearcher();
syncFragments();
// new Reaction(reaction);
Reaction rxn = getReaction();
// Mark the manually mapped atoms, so we may re-assign them later
for (int i = 0; i < rxn.getMolecules(); i++) {
StereoMolecule mol = rxn.getMolecule(i);
for (int a = 0; a < mol.getAtoms(); a++) {
if (mol.getAtomMapNo(a) > 0) {
mol.setAtomicNo(a, FAKE_ATOM_NO + mol.getAtomMapNo(a));
}
}
}
rxn = mMapper.matchReaction(rxn, sss);
if (rxn != null) {
int offset = 0;
// Sync the display molecule with the reaction fragments
{
int[] fragmentAtom = new int[mFragment.length];
for (int atom = 0; atom < mMol.getAllAtoms(); atom++) {
int fragment = mFragmentNo[atom];
if (mFragment[fragment].getAtomicNo(fragmentAtom[fragment]) > FAKE_ATOM_NO) {
mMol.setAtomMapNo(atom, mFragment[fragment].getAtomicNo(fragmentAtom[fragment]) - FAKE_ATOM_NO, false);
offset = Math.max(mMol.getAtomMapNo(atom), offset);
}
fragmentAtom[fragment]++;
}
}
{
int[] fragmentAtom = new int[mFragment.length];
for (int atom = 0; atom < mMol.getAllAtoms(); atom++) {
int fragment = mFragmentNo[atom];
if (mFragment[fragment].getAtomMapNo(fragmentAtom[fragment]) > 0 && (mFragment[fragment].getAtomicNo(fragmentAtom[fragment]) <= FAKE_ATOM_NO)) {
mMol.setAtomMapNo(atom, mFragment[fragment].getAtomMapNo(fragmentAtom[fragment]) + offset, true);
}
fragmentAtom[fragment]++;
}
}
}
syncFragments();
// mMapper.resetFragments(mappedReaction);
// AStarReactionMapper m = new AStarReactionMapper();
// Reaction rxn = getReaction();
// List<AStarReactionMapper.SlimMapping> l = m.map(rxn);
// if (l != null && l.size() > 0) {
// AStarReactionMapper.SlimMapping sm = l.get(0);
// // int[] mps = sm.getMapping();
// // for (int i = 0; i < mps.length; i++) {
// // System.out.printf("Maps %d -> %d\n", i, mps[i]);
// // }
// m.activateMapping(sm);
// // for (int i = 0; i < mFragment.length; i++) {
// // StereoMolecule mol = mFragment[i];
// // for (int a = 0; a < mol.getAllAtoms(); a++) {
// // System.out.printf("T Map %d = %d\n", a, mol.getAtomMapNo(a));
// // }
// // }
//
// int[] fragmentAtom = new int[mFragment.length];
// for (int atom = 0; atom < mMol.getAllAtoms(); atom++) {
// int fragment = mFragmentNo[atom];
// if (mMol.getAtomMapNo(atom) == 0)
// mMol.setAtomMapNo(atom, mFragment[fragment].getAtomMapNo(fragmentAtom[fragment]), true);
// fragmentAtom[fragment]++;
// }
// }
}
use of com.actelion.research.chem.reaction.Reaction in project openchemlib by Actelion.
the class JDrawArea method setReactionMode.
public void setReactionMode(boolean rxn) {
if (rxn) {
Molecule[] m = this.getFragments();
if (m == null) {
setReaction(new Reaction(new StereoMolecule[] { new StereoMolecule(this.getMolecule()) }, 1));
} else {
mMode = MODE_MULTIPLE_FRAGMENTS | MODE_REACTION;
Reaction r = getReaction();
setReaction(r);
}
} else {
mMode &= ~MODE_REACTION;
}
}
use of com.actelion.research.chem.reaction.Reaction in project openchemlib by Actelion.
the class Model method tryAutoMapReaction.
public void tryAutoMapReaction() {
SSSearcher sss = new MySSSearcher();
// new Reaction(reaction);
Reaction rxn = getReaction();
// Mark the manually mapped atoms, so we may re-assign them later
for (int i = 0; i < rxn.getMolecules(); i++) {
StereoMolecule mol = rxn.getMolecule(i);
for (int a = 0; a < mol.getAtoms(); a++) {
if (mol.getAtomMapNo(a) > 0) {
mol.setAtomicNo(a, FAKE_ATOM_NO + mol.getAtomMapNo(a));
}
}
}
rxn = mapper.matchReaction(rxn, sss);
if (rxn != null) {
int offset = 0;
// Sync the display molecule with the reaction fragments
{
int[] fragmentAtom = new int[mFragment.length];
for (int atom = 0; atom < mMol.getAllAtoms(); atom++) {
int fragment = mFragmentNo[atom];
if (mFragment[fragment].getAtomicNo(fragmentAtom[fragment]) > FAKE_ATOM_NO) {
mMol.setAtomMapNo(atom, mFragment[fragment].getAtomicNo(fragmentAtom[fragment]) - FAKE_ATOM_NO, false);
offset = Math.max(mMol.getAtomMapNo(atom), offset);
}
fragmentAtom[fragment]++;
}
}
{
int[] fragmentAtom = new int[mFragment.length];
for (int atom = 0; atom < mMol.getAllAtoms(); atom++) {
int fragment = mFragmentNo[atom];
if (mFragment[fragment].getAtomMapNo(fragmentAtom[fragment]) > 0 && (mFragment[fragment].getAtomicNo(fragmentAtom[fragment]) <= FAKE_ATOM_NO)) {
mMol.setAtomMapNo(atom, mFragment[fragment].getAtomMapNo(fragmentAtom[fragment]) + offset, true);
}
fragmentAtom[fragment]++;
}
}
}
syncFragments();
}
Aggregations