Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Pushed in a new CDK 1.3.0.+ version plus updated JChemPaint-Primary
  • Loading branch information
egonw committed Oct 1, 2009
1 parent d075a6e commit 5f0923d
Show file tree
Hide file tree
Showing 168 changed files with 3,272 additions and 957 deletions.
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CDK plugin
Bundle-SymbolicName: org.openscience.cdk.atomtype;singleton:=true
Bundle-Version: 1.3.0.0bioclipse1
Bundle-Version: 1.3.0.0bioclipse4
Bundle-Vendor: The Chemistry Development Kit Project
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.openscience.cdk.atomtype.Activator
Expand Down
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CDK plugin
Bundle-SymbolicName: org.openscience.cdk.builder3d;singleton:=true
Bundle-Version: 1.3.0.0bioclipse1
Bundle-Version: 1.3.0.0bioclipse4
Bundle-Vendor: The Chemistry Development Kit Project
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.openscience.cdk.builder3d.Activator
Expand Down
Expand Up @@ -20,20 +20,22 @@
*/
package org.openscience.cdk.modeling.builder3d;

import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.vecmath.Point2d;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;

import org.openscience.cdk.AtomContainer;
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.geometry.GeometryTools;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;

import javax.vecmath.Point2d;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
import java.util.Iterator;
import java.util.List;
import java.util.Map;


/**
* Place aliphatic chains with Z matrix method.
Expand Down Expand Up @@ -111,9 +113,8 @@ public IAtomContainer markPlaced(IAtomContainer ac) {
* Method assigns 3Dcoordinates to the heavy atoms in an aliphatic chain
*
* @param chain the atoms to be assigned, must be connected
* @exception Exception Description of the Exception
*/
public void placeAliphaticHeavyChain(IAtomContainer molecule, IAtomContainer chain) throws Exception {
public void placeAliphaticHeavyChain(IAtomContainer molecule, IAtomContainer chain) throws CDKException{
//logger.debug("******** Place aliphatic Chain *********");
int[] first = new int[2];
int counter = 1;
Expand Down Expand Up @@ -171,7 +172,7 @@ public void placeAliphaticHeavyChain(IAtomContainer molecule, IAtomContainer cha
==5){
dihedrals[counter] = DIHEDRAL_BRANCHED_CHAIN;
}else{ dihedrals[counter] = DIHEDRAL_EXTENDED_CHAIN;}
}catch(Exception ex1){
}catch(CDKException ex1){
dihedrals[counter] = DIHEDRAL_EXTENDED_CHAIN;
}
} else {
Expand Down Expand Up @@ -287,9 +288,8 @@ private int getHybridisationState(IAtom atom1) {
*@param c coordinates (Point2d) of atom3 connected to bond
*@param d coordinates (Point2d) of atom4 connected to bond
*@return The doubleBondConfiguration2D value
*@exception Exception Description of the Exception
*/
private int getDoubleBondConfiguration2D(IBond bond,Point2d a, Point2d b,Point2d c,Point2d d) throws Exception{
private int getDoubleBondConfiguration2D(IBond bond,Point2d a, Point2d b,Point2d c,Point2d d) throws CDKException{
if (bond.getOrder() != IBond.Order.DOUBLE){
return 0;
}
Expand All @@ -308,9 +308,8 @@ private int getDoubleBondConfiguration2D(IBond bond,Point2d a, Point2d b,Point2d
* @param id1 atom1 id
* @param id2 atom2 id
* @return The distanceValue value from the force field parameter set
* @exception Exception Description of the Exception
*/
public double getBondLengthValue(String id1, String id2) throws Exception {
public double getBondLengthValue(String id1, String id2){
String dkey = "";
if (pSet.containsKey(("bond" + id1 + ";" + id2))) {
dkey="bond" + id1 + ";" + id2;
Expand All @@ -330,9 +329,8 @@ public double getBondLengthValue(String id1, String id2) throws Exception {
* @param id2 Description of the Parameter
* @param id3 Description of the Parameter
* @return The angleKey value
* @exception Exception Description of the Exception
*/
public double getAngleValue(String id1, String id2, String id3) throws Exception {
public double getAngleValue(String id1, String id2, String id3) {
String akey = "";
if (pSet.containsKey(("angle" + id1 + ";" + id2 + ";" + id3))) {
akey = "angle" + id1 + ";" + id2 + ";" + id3;
Expand Down
Expand Up @@ -776,7 +776,7 @@ public int makeStereocenter(Point3d atomA, IBond ax, Point3d atomB, Point3d atom
n1.normalize();

if (getSpatproduct(b, c, n1) >= 0) {
if (ax.getStereo() != CDKConstants.STEREO_BOND_UP_INV) {
if (ax.getStereo() != IBond.Stereo.UP_INVERTED) {
n1.cross(c, b);
n1.normalize();
}
Expand Down
Expand Up @@ -34,6 +34,7 @@

import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.exception.NoSuchAtomTypeException;
import org.openscience.cdk.geometry.GeometryTools;
import org.openscience.cdk.graph.ConnectivityChecker;
import org.openscience.cdk.interfaces.IAtom;
Expand Down Expand Up @@ -139,7 +140,7 @@ private void setForceField(String ffname) throws CDKException {
forceFieldName = ffname;
ffc.setForceFieldConfigurator(ffname);
parameterSet = ffc.getParameterSet();
} catch (Exception ex1) {
} catch (CDKException ex1) {
logger.error("Problem with ForceField configuration due to>" + ex1.getMessage());
logger.debug(ex1);
throw new CDKException("Problem with ForceField configuration due to>" + ex1.getMessage(), ex1);
Expand All @@ -150,7 +151,9 @@ private void setForceField(String ffname) throws CDKException {
/**
* Generate 3D coordinates with force field information.
*/
public IMolecule generate3DCoordinates(IMolecule molecule, boolean clone) throws Exception {
public IMolecule generate3DCoordinates(IMolecule molecule, boolean clone)
throws CDKException, NoSuchAtomTypeException,
CloneNotSupportedException, IOException{
String[] originalAtomTypeNames = new String[molecule.getAtomCount()];
for (int i=0; i<originalAtomTypeNames.length; i++) {
originalAtomTypeNames[i] = molecule.getAtom(i).getAtomTypeName();
Expand Down Expand Up @@ -182,7 +185,7 @@ public IMolecule generate3DCoordinates(IMolecule molecule, boolean clone) throws
molecule.getAtom(0).setPoint3d(new Point3d(0.0, 0.0, 0.0));
try {
atlp3d.add3DCoordinatesForSinglyBondedLigands(molecule);
} catch (Exception ex3) {
} catch (CDKException ex3) {
logger.error("PlaceSubstitutensERROR: Cannot place substitutents due to:" + ex3.getMessage());
logger.debug(ex3);
throw new CDKException("PlaceSubstitutensERROR: Cannot place substitutents due to:" + ex3.getMessage(), ex3);
Expand Down Expand Up @@ -227,10 +230,10 @@ public IMolecule generate3DCoordinates(IMolecule molecule, boolean clone) throws
//logger.debug("******* PLACE SUBSTITUENTS ******");
try {
atlp3d.add3DCoordinatesForSinglyBondedLigands(molecule);
} catch (Exception ex3) {
} catch (CDKException ex3) {
logger.error("PlaceSubstitutensERROR: Cannot place substitutents due to:" + ex3.getMessage());
logger.debug(ex3);
throw new Exception("PlaceSubstitutensERROR: Cannot place substitutents due to:" + ex3.getMessage(), ex3);
throw new CDKException("PlaceSubstitutensERROR: Cannot place substitutents due to:" + ex3.getMessage(), ex3);
}
// restore the original atom type names
for (int i=0; i<originalAtomTypeNames.length; i++) {
Expand Down Expand Up @@ -262,9 +265,8 @@ private IRingSet getRingSetOfAtom(List ringSystems, IAtom atom) {
* Layout the molecule, starts with ring systems and than aliphatic chains.
*
*@param ringSetMolecule ringSystems of the molecule
*@exception Exception Description of the Exception
*/
private void layoutMolecule(List ringSetMolecule, IMolecule molecule, AtomPlacer3D ap3d, AtomTetrahedralLigandPlacer3D atlp3d, AtomPlacer atomPlacer) throws Exception {
private void layoutMolecule(List ringSetMolecule, IMolecule molecule, AtomPlacer3D ap3d, AtomTetrahedralLigandPlacer3D atlp3d, AtomPlacer atomPlacer) throws CDKException, IOException, CloneNotSupportedException {
//logger.debug("****** LAYOUT MOLECULE MAIN *******");
IAtomContainer ac = null;
int safetyCounter = 0;
Expand Down Expand Up @@ -403,9 +405,8 @@ private void layoutRingSystem(Point3d originalCoord, IAtom placedRingAtom, IRing
*@param unplacedAtom The new branchAtom
*@param atomA placed atom to which the unplaced satom is connected
*@param atomNeighbours placed atomNeighbours of atomA
*@exception Exception Description of the Exception
*/
private void setBranchAtom(IMolecule molecule, IAtom unplacedAtom, IAtom atomA, IAtomContainer atomNeighbours, AtomPlacer3D ap3d, AtomTetrahedralLigandPlacer3D atlp3d) throws Exception {
private void setBranchAtom(IMolecule molecule, IAtom unplacedAtom, IAtom atomA, IAtomContainer atomNeighbours, AtomPlacer3D ap3d, AtomTetrahedralLigandPlacer3D atlp3d) throws CDKException {
//logger.debug("****** SET Branch Atom ****** >"+molecule.getAtomNumber(unplacedAtom));
IAtomContainer noCoords = molecule.getBuilder().newAtomContainer();
noCoords.addAtom(unplacedAtom);
Expand All @@ -431,21 +432,18 @@ private void setBranchAtom(IMolecule molecule, IAtom unplacedAtom, IAtom atomA,
, length, angle);
double distance = 0;
int farthestPoint = 0;
try {
for (int i = 0; i < branchPoints.length; i++) {
if (Math.abs(branchPoints[i].distance(centerPlacedMolecule)) > Math.abs(distance)) {
distance = branchPoints[i].distance(centerPlacedMolecule);
farthestPoint = i;
}
for (int i = 0; i < branchPoints.length; i++) {
if (Math.abs(branchPoints[i].distance(centerPlacedMolecule)) > Math.abs(distance)) {
distance = branchPoints[i].distance(centerPlacedMolecule);
farthestPoint = i;
}
} catch (Exception ex2) {
throw new IOException("SetBranchAtomERROR: Not enough branch Points");
}

int stereo = -1;
IBond unplacedBond = molecule.getBond(atomA, unplacedAtom);
if (atomA.getStereoParity() != CDKConstants.UNSET && atomA.getStereoParity() != 0 ||
(Math.abs((molecule.getBond(atomA, unplacedAtom)).getStereo()) < 2
&& Math.abs((molecule.getBond(atomA, unplacedAtom)).getStereo()) != 0)
(unplacedBond.getStereo() == IBond.Stereo.UP ||
unplacedBond.getStereo() == IBond.Stereo.DOWN)
&& molecule.getMaximumBondOrder(atomA) == IBond.Order.SINGLE) {
if (atomNeighbours.getAtomCount() > 1) {
stereo = atlp3d.makeStereocenter(atomA.getPoint3d(), molecule.getBond(atomA, unplacedAtom), (atomNeighbours.getAtom(0)).getPoint3d(), (atomNeighbours.getAtom(1)).getPoint3d(), branchPoints);
Expand All @@ -463,9 +461,8 @@ private void setBranchAtom(IMolecule molecule, IAtom unplacedAtom, IAtom atomA,
* Search and place branches of a chain or ring.
*
*@param chain AtomContainer if atoms in an aliphatic chain or ring system
*@exception Exception Description of the Exception
*/
private void searchAndPlaceBranches(IMolecule molecule, IAtomContainer chain, AtomPlacer3D ap3d, AtomTetrahedralLigandPlacer3D atlp3d, AtomPlacer atomPlacer) throws Exception {
private void searchAndPlaceBranches(IMolecule molecule, IAtomContainer chain, AtomPlacer3D ap3d, AtomTetrahedralLigandPlacer3D atlp3d, AtomPlacer atomPlacer) throws CDKException {
//logger.debug("****** SEARCH AND PLACE ****** Chain length: "+chain.getAtomCount());
java.util.List atoms = null;
IAtomContainer branchAtoms = molecule.getBuilder().newAtomContainer();
Expand All @@ -476,18 +473,13 @@ private void searchAndPlaceBranches(IMolecule molecule, IAtomContainer chain, At
IAtom atom = (IAtom)atoms.get(j);
if (!(atom.getSymbol()).equals("H") & !(atom.getFlag(CDKConstants.ISPLACED)) & !(atom.getFlag(CDKConstants.ISINRING))) {
//logger.debug("SEARCH PLACE AND FOUND Branch Atom "+molecule.getAtomNumber(chain.getAtomAt(i))+
// " New Atom:"+molecule.getAtomNumber(atoms[j])+" -> STORE");
try {
connectedAtoms.add(ap3d.getPlacedHeavyAtoms(molecule, chain.getAtom(i)));
//logger.debug("Connected atom1:"+molecule.getAtomNumber(connectedAtoms.getAtomAt(0))+" atom2:"+
//molecule.getAtomNumber(connectedAtoms.getAtomAt(1))+ " Length:"+connectedAtoms.getAtomCount());
} catch (Exception ex1) {
logger.error("SearchAndPlaceBranchERROR: Cannot find connected placed atoms due to" + ex1.toString());
throw new IOException("SearchAndPlaceBranchERROR: Cannot find connected placed atoms");
}
// " New Atom:"+molecule.getAtomNumber(atoms[j])+" -> STORE");
connectedAtoms.add(ap3d.getPlacedHeavyAtoms(molecule, chain.getAtom(i)));
//logger.debug("Connected atom1:"+molecule.getAtomNumber(connectedAtoms.getAtomAt(0))+" atom2:"+
//molecule.getAtomNumber(connectedAtoms.getAtomAt(1))+ " Length:"+connectedAtoms.getAtomCount());
try {
setBranchAtom(molecule, atom, chain.getAtom(i), connectedAtoms, ap3d, atlp3d);
} catch (Exception ex2) {
} catch (CDKException ex2) {
logger.error("SearchAndPlaceBranchERROR: Cannot find enough neighbour atoms due to" + ex2.toString());
throw new CDKException("SearchAndPlaceBranchERROR: Cannot find enough neighbour atoms: " + ex2.getMessage(), ex2);
}
Expand All @@ -505,9 +497,8 @@ private void searchAndPlaceBranches(IMolecule molecule, IAtomContainer chain, At
* Layout all aliphatic chains with ZMatrix.
*
*@param startAtoms AtomContainer of possible start atoms for a chain
*@exception Exception Description of the Exception
*/
private void placeLinearChains3D(IMolecule molecule, IAtomContainer startAtoms, AtomPlacer3D ap3d, AtomTetrahedralLigandPlacer3D atlp3d, AtomPlacer atomPlacer) throws Exception {
private void placeLinearChains3D(IMolecule molecule, IAtomContainer startAtoms, AtomPlacer3D ap3d, AtomTetrahedralLigandPlacer3D atlp3d, AtomPlacer atomPlacer) throws CDKException {
//logger.debug("****** PLACE LINEAR CHAINS ******");
IAtom dihPlacedAtom = null;
IAtom thirdPlacedAtom = null;
Expand Down
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CDK plugin
Bundle-SymbolicName: org.openscience.cdk.charges;singleton:=true
Bundle-Version: 1.3.0.0bioclipse1
Bundle-Version: 1.3.0.0bioclipse4
Bundle-Vendor: The Chemistry Development Kit Project
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.openscience.cdk.charges.Activator
Expand Down
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CDK plugin
Bundle-SymbolicName: org.openscience.cdk.control;singleton:=true
Bundle-Version: 1.3.0.0bioclipse1
Bundle-Version: 1.3.0.0bioclipse4
Bundle-Vendor: The Chemistry Development Kit Project
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.openscience.cdk.control.Activator
Expand Down
Expand Up @@ -8,6 +8,7 @@ org/openscience/cdk/controller/undoredo/IUndoRedoFactory.java
org/openscience/cdk/controller/undoredo/IUndoRedoable.java
org/openscience/cdk/controller/undoredo/IUndoListener.java
org/openscience/cdk/controller/IControllerModule.java
org/openscience/cdk/controller/IAtomBondEdits.java
org/openscience/cdk/controller/IChemModelRelay.java
org/openscience/cdk/controller/edit/IEdit.java
org/openscience/cdk/controller/IMouseEventRelay.java
Expand Down
Expand Up @@ -92,6 +92,7 @@ public void mouseMove(Point2d worldCoord) {
}

public void setChemModelRelay(IChemModelRelay relay) {
this.chemModelRelay = relay;
}

protected IChemObject getHighlighted( Point2d worldCoord, IChemObject... objects ) {
Expand Down Expand Up @@ -135,15 +136,13 @@ protected IAtomContainer getSelectedAtomContainer(Point2d worldCoord) {
IChemObjectSelection localSelection = rModel.getSelection();
IChemObject chemObject = getHighlighted(worldCoord, atom, bond);

// FIXME added null check for if rModel.getSelection() return null
if (localSelection!=null && !localSelection.contains(chemObject)) {
if (!localSelection.contains(chemObject)) {
if (chemObject != null) {
localSelection = new SingleSelection<IChemObject>(chemObject);
} else {
localSelection = AbstractSelection.EMPTY_SELECTION;
}
}
if(localSelection==null) localSelection = AbstractSelection.EMPTY_SELECTION;
setSelection(localSelection);
return selection.getConnectedAtomContainer();
}
Expand Down
@@ -0,0 +1,74 @@
/*
* Copyright (C) 2009 Arvid Berg <goglepox@users.sourceforge.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* All I ask is that proper credit is given for my work, which includes
* - but is not limited to - adding the above copyright notice to the beginning
* of your source code files, and to any copyright notice that you may distribute
* with programs based on this work.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.openscience.cdk.controller;

import javax.vecmath.Point2d;
import javax.vecmath.Vector2d;

import org.openscience.cdk.controller.IChemModelRelay.Direction;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;

/**
* Interface for edit methods currently used by edit modules but should
* be replaced by IEdit commands.
* @author Arvid
* @cdk.module control
* @deprecated Use <code>IEdits</code> instead
*/
@Deprecated
public interface IAtomBondEdits {
/* Editing actions for atoms */
public IAtomContainer removeAtom(IAtom atom);
public IAtomContainer removeAtomWithoutUndo(IAtom atom);
public IAtom addAtom(String element, Point2d worldcoord);
public IAtom addAtomWithoutUndo(String element, Point2d worldcoord);
public IAtom addAtom(String element, IAtom atom);
public IAtom addAtomWithoutUndo(String element, IAtom atom);
public void moveToWithoutUndo(IAtom atom, Point2d point);
public void moveTo(IAtom atom, Point2d point);
public void setSymbol(IAtom atom, String symbol);
public void setCharge(IAtom atom, int charge);
public void setMassNumber(IAtom atom, int charge);
public void setHydrogenCount(IAtom atom, int intValue);
public void replaceAtom(IAtom atomnew, IAtom atomold);
public void addSingleElectron(IAtom atom);
public void updateAtoms(IAtomContainer container, Iterable<IAtom> atoms);
public void updateAtom(IAtom atom);
public void mergeMolecules(Vector2d movedDistance);

/* Editing actions for bonds */
public IBond addBond(IAtom fromAtom, IAtom toAtom);
public void removeBondWithoutUndo(IBond bond);
public void removeBond(IBond bond);
public void moveToWithoutUndo(IBond bond, Point2d point);
public void moveTo(IBond bond, Point2d point);
public void setOrder(IBond bond, IBond.Order order);
public void setWedgeType(IBond bond, IBond.Stereo type);
public void addNewBond(Point2d worldCoordinate);
public void cycleBondValence(IBond bond);
public void makeBondStereo(IBond bond, Direction desiredDirection);
public IBond makeNewStereoBond(IAtom atom, Direction desiredDirection);
}

0 comments on commit 5f0923d

Please sign in to comment.