[Nmrshiftdb-devel] CVS: nmrshiftdb/src/java/org/openscience/nmrshiftdb/util AtomUtils.java, 1.163,
Brought to you by:
steinbeck
|
From: Stefan K. <sh...@us...> - 2006-10-09 13:24:46
|
Update of /cvsroot/nmrshiftdb/nmrshiftdb/src/java/org/openscience/nmrshiftdb/util In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv21218/src/java/org/openscience/nmrshiftdb/util Modified Files: AtomUtils.java GeneralUtils.java SubmittingData.java Log Message: this uses new cdk and new saturation stuff. should resolve a long standing problem Index: AtomUtils.java =================================================================== RCS file: /cvsroot/nmrshiftdb/nmrshiftdb/src/java/org/openscience/nmrshiftdb/util/AtomUtils.java,v retrieving revision 1.163 retrieving revision 1.164 diff -C2 -r1.163 -r1.164 *** AtomUtils.java 28 Aug 2006 14:33:58 -0000 1.163 --- AtomUtils.java 9 Oct 2006 13:24:38 -0000 1.164 *************** *** 8,11 **** --- 8,13 ---- import java.util.BitSet; import java.util.HashMap; + import java.util.Iterator; + import java.util.List; import java.util.Map; import java.util.Vector; *************** *** 53,57 **** import org.openscience.cdk.tools.HydrogenAdder; import org.openscience.cdk.tools.Normalizer; ! import org.openscience.cdk.tools.manipulator.SetOfAtomContainersManipulator; import org.openscience.nmrshiftdb.PredictionTool; import org.openscience.nmrshiftdb.om.DBBond; --- 55,59 ---- import org.openscience.cdk.tools.HydrogenAdder; import org.openscience.cdk.tools.Normalizer; ! import org.openscience.cdk.tools.manipulator.AtomContainerSetManipulator; import org.openscience.nmrshiftdb.PredictionTool; import org.openscience.nmrshiftdb.om.DBBond; *************** *** 175,179 **** IBond[] bonds = cdkmol.getBonds(); for (int l = 0; l < bonds.length; l++) { ! if (bonds[l].getAtom(0) == cdkmol.getConnectedAtoms(cdkmol.getAtom(atomnumber))[0] || bonds[l].getAtom(1) == cdkmol.getConnectedAtoms(cdkmol.getAtom(atomnumber))[0]) { if (bonds[l].getOrder() == 2) { class2 = true; --- 177,181 ---- IBond[] bonds = cdkmol.getBonds(); for (int l = 0; l < bonds.length; l++) { ! if (bonds[l].getAtom(0) == cdkmol.getConnectedAtomsList(cdkmol.getAtom(atomnumber)).get(0) || bonds[l].getAtom(1) == cdkmol.getConnectedAtomsList(cdkmol.getAtom(atomnumber)).get(0)) { if (bonds[l].getOrder() == 2) { class2 = true; *************** *** 181,187 **** } } ! if (cdkmol.getConnectedAtoms(cdkmol.getAtom(atomnumber))[0].getFlag(CDKConstants.ISAROMATIC)) { protonclass = 1; ! } else if (allrings.getRings(cdkmol.getConnectedAtoms(cdkmol.getAtom(atomnumber))[0]).getAtomContainerCount() > 0) { protonclass = 3; } else if (class2) { --- 183,189 ---- } } ! if (((IAtom)cdkmol.getConnectedAtomsList(cdkmol.getAtom(atomnumber)).get(0)).getFlag(CDKConstants.ISAROMATIC)) { protonclass = 1; ! } else if (allrings.getRings((IAtom)cdkmol.getConnectedAtomsList(cdkmol.getAtom(atomnumber)).get(0)).getAtomContainerCount() > 0) { protonclass = 3; } else if (class2) { *************** *** 242,246 **** floats[2] = ((float) l.doubleValue()); floats[3] = (float) (a.getCharge()); ! floats[4] = (float) (ac.getConnectedAtoms(a)[0].getCharge()); if (hcg == null) { hcg = new HOSECodeGenerator(); --- 244,248 ---- floats[2] = ((float) l.doubleValue()); floats[3] = (float) (a.getCharge()); ! floats[4] = (float) (((IAtom)ac.getConnectedAtomsList(a).get(0)).getCharge()); if (hcg == null) { hcg = new HOSECodeGenerator(); *************** *** 342,351 **** } if(protonclass==2){ ! IAtom firstheavy=ac.getConnectedAtoms(a)[0]; ! IBond[] bondsoffirstheavy=ac.getConnectedBonds(firstheavy); IBond doublebond=null; ! for(int k=0;k<bondsoffirstheavy.length;k++){ ! if(bondsoffirstheavy[k].getOrder()==2){ ! doublebond=bondsoffirstheavy[k]; break; } --- 344,353 ---- } if(protonclass==2){ ! IAtom firstheavy=(IAtom)ac.getConnectedAtomsList(a).get(0); ! List bondsoffirstheavy=ac.getConnectedBondsList(firstheavy); IBond doublebond=null; ! for(int k=0;k<bondsoffirstheavy.size();k++){ ! if(((IBond)bondsoffirstheavy.get(k)).getOrder()==2){ ! doublebond=(IBond)bondsoffirstheavy.get(k); break; } *************** *** 362,370 **** dr = (DoubleResult) epdes.calculate(secondheavy,ac).getValue(); floats[91] = ((float) dr.doubleValue()); ! IAtom[] atomsonfirst=ac.getConnectedAtoms(firstheavy); IAtom otheronfirstheavy=null; ! for(int k=0;k<atomsonfirst.length;k++){ ! if(atomsonfirst[k]!=secondheavy && atomsonfirst[k]!=a){ ! otheronfirstheavy=atomsonfirst[k]; break; } --- 364,372 ---- dr = (DoubleResult) epdes.calculate(secondheavy,ac).getValue(); floats[91] = ((float) dr.doubleValue()); ! List atomsonfirst=ac.getConnectedAtomsList(firstheavy); IAtom otheronfirstheavy=null; ! for(int k=0;k<atomsonfirst.size();k++){ ! if(atomsonfirst.get(k)!=secondheavy && atomsonfirst.get(k)!=a){ ! otheronfirstheavy=(IAtom)atomsonfirst.get(k); break; } *************** *** 373,383 **** IAtom firstonsecond=null; IAtom secondonsecond=null; ! IAtom[] connectedtosecond=ac.getConnectedAtoms(secondheavy); ! for(int k=0;k<connectedtosecond.length;k++){ ! if(connectedtosecond[k]!=firstheavy){ if(firstonsecond==null){ ! firstonsecond=connectedtosecond[k]; }else{ ! secondonsecond=connectedtosecond[k]; break; } --- 375,385 ---- IAtom firstonsecond=null; IAtom secondonsecond=null; ! List connectedtosecond=ac.getConnectedAtomsList(secondheavy); ! for(int k=0;k<connectedtosecond.size();k++){ ! if(connectedtosecond.get(k)!=firstheavy){ if(firstonsecond==null){ ! firstonsecond=(IAtom)connectedtosecond.get(k); }else{ ! secondonsecond=(IAtom)connectedtosecond.get(k); break; } *************** *** 412,416 **** floats[startfield+2] = ((float) dr.doubleValue()); IAtomContainerSet acSet = ConjugatedPiSystemsDetector.detect(ac); ! IAtomContainer piac=(IAtomContainer)SetOfAtomContainersManipulator.getAllInOneContainer(acSet); floats[startfield+3]=0; for(int k=0;k<piac.getAtomCount();k++){ --- 414,418 ---- floats[startfield+2] = ((float) dr.doubleValue()); IAtomContainerSet acSet = ConjugatedPiSystemsDetector.detect(ac); ! IAtomContainer piac=(IAtomContainer)AtomContainerSetManipulator.getAllInOneContainer(acSet); floats[startfield+3]=0; for(int k=0;k<piac.getAtomCount();k++){ *************** *** 460,464 **** */ public static float[] getDescriptorSet(DBCondition temp, DBCondition field, DBCondition solvent, IAtomContainer ac, IAtom a, IRingSet rs, int protonclass) throws Exception { ! IAtom atomInFocus = ac.getConnectedAtoms(a)[0]; Integer atomInFocusInt = new Integer(ac.getAtomNumber(atomInFocus)); AtomHybridizationVSEPRDescriptor hybdes = new AtomHybridizationVSEPRDescriptor(); --- 462,466 ---- */ public static float[] getDescriptorSet(DBCondition temp, DBCondition field, DBCondition solvent, IAtomContainer ac, IAtom a, IRingSet rs, int protonclass) throws Exception { ! IAtom atomInFocus = (IAtom)ac.getConnectedAtomsList(a).get(0); Integer atomInFocusInt = new Integer(ac.getAtomNumber(atomInFocus)); AtomHybridizationVSEPRDescriptor hybdes = new AtomHybridizationVSEPRDescriptor(); *************** *** 483,489 **** floats[3] = (float) (atomInFocus.getFormalNeighbourCount() - floats[2]); int substituents = 0; ! IAtom[] v = ac.getConnectedAtoms(atomInFocus); ! for (int i = 0; i < v.length; i++) { ! if (!v[i].getSymbol().equals("H")) { substituents++; } --- 485,491 ---- floats[3] = (float) (atomInFocus.getFormalNeighbourCount() - floats[2]); int substituents = 0; ! List v = ac.getConnectedAtomsList(atomInFocus); ! for (int i = 0; i < v.size(); i++) { ! if (!((IAtom)v.get(i)).getSymbol().equals("H")) { substituents++; } *************** *** 500,504 **** int sumValenceElectrons = 0; Vector closestInSpace = GeometryTools.findClosestInSpace(ac, atomInFocus, 16); ! IAtom[] connectedAtoms = ac.getConnectedAtoms(atomInFocus); for (int i = 0; i < closestInSpace.size(); i++) { IAtom closest = (IAtom) closestInSpace.get(i); --- 502,506 ---- int sumValenceElectrons = 0; Vector closestInSpace = GeometryTools.findClosestInSpace(ac, atomInFocus, 16); ! List connectedAtoms = ac.getConnectedAtomsList(atomInFocus); for (int i = 0; i < closestInSpace.size(); i++) { IAtom closest = (IAtom) closestInSpace.get(i); *************** *** 545,554 **** double distanceAll = 0; int numberofhs = 0; ! for (int k = 0; k < connectedAtoms.length; k++) { ! if (connectedAtoms[k].getSymbol().equals("H")) { numberofhs++; ! distanceAll += connectedAtoms[k].getPoint3d().distance(closest.getPoint3d()); ! if (connectedAtoms[k].getPoint3d().distance(closest.getPoint3d()) < distanceMin) { ! distanceMin = connectedAtoms[k].getPoint3d().distance(closest.getPoint3d()); } } --- 547,556 ---- double distanceAll = 0; int numberofhs = 0; ! for (int k = 0; k < connectedAtoms.size(); k++) { ! if (((IAtom)connectedAtoms.get(k)).getSymbol().equals("H")) { numberofhs++; ! distanceAll += ((IAtom)connectedAtoms.get(k)).getPoint3d().distance(closest.getPoint3d()); ! if (((IAtom)connectedAtoms.get(k)).getPoint3d().distance(closest.getPoint3d()) < distanceMin) { ! distanceMin = ((IAtom)connectedAtoms.get(k)).getPoint3d().distance(closest.getPoint3d()); } } *************** *** 608,617 **** double distanceAll = 0; int numberofhs = 0; ! for (int k = 0; k < connectedAtoms.length; k++) { ! if (connectedAtoms[k].getSymbol().equals("H")) { numberofhs++; ! distanceAll += connectedAtoms[k].getPoint3d().distance(closestByBond[i].getPoint3d()); ! if (connectedAtoms[k].getPoint3d().distance(closestByBond[i].getPoint3d()) < distanceMin) { ! distanceMin = connectedAtoms[k].getPoint3d().distance(closestByBond[i].getPoint3d()); } } --- 610,619 ---- double distanceAll = 0; int numberofhs = 0; ! for (int k = 0; k < connectedAtoms.size(); k++) { ! if (((IAtom)connectedAtoms.get(k)).getSymbol().equals("H")) { numberofhs++; ! distanceAll += ((IAtom)connectedAtoms.get(k)).getPoint3d().distance(closestByBond[i].getPoint3d()); ! if (((IAtom)connectedAtoms.get(k)).getPoint3d().distance(closestByBond[i].getPoint3d()) < distanceMin) { ! distanceMin = ((IAtom)connectedAtoms.get(k)).getPoint3d().distance(closestByBond[i].getPoint3d()); } } *************** *** 684,688 **** */ public static boolean checkIfOnlyOneStructure(IMolecule mol) { ! if (setThisAtomAsLinked(mol.getAtoms()[0], mol, 0) == mol.getAtoms().length) { return (true); } else { --- 686,690 ---- */ public static boolean checkIfOnlyOneStructure(IMolecule mol) { ! if (setThisAtomAsLinked(mol.getAtom(0), mol, 0) == mol.getAtomCount()) { return (true); } else { *************** *** 732,736 **** if (sg.isValidDoubleBondConfiguration(mol, bonds[i])) { StringAndIntAndBoolean sai = new StringAndIntAndBoolean(); ! sai.myString = new String((mol.getAtomNumber(bonds[i].getAtoms()[0]) + 1) + " = " + (mol.getAtomNumber(bonds[i].getAtoms()[1]) + 1)); sai.myInt = i; if (dbbonds != null) { --- 734,738 ---- if (sg.isValidDoubleBondConfiguration(mol, bonds[i])) { StringAndIntAndBoolean sai = new StringAndIntAndBoolean(); ! sai.myString = new String((mol.getAtomNumber(bonds[i].getAtom(0)) + 1) + " = " + (mol.getAtomNumber(bonds[i].getAtom(1)) + 1)); sai.myInt = i; if (dbbonds != null) { *************** *** 859,863 **** for (int i = 0; i < container.getAtomCount(); i++) { IAtom a = container.getAtom(i); ! if (container.getConnectedAtoms(a).length == 4) { int up = 0; int down = 0; --- 861,865 ---- for (int i = 0; i < container.getAtomCount(); i++) { IAtom a = container.getAtom(i); ! if (container.getConnectedAtomsList(a).size() == 4) { int up = 0; int down = 0; *************** *** 865,876 **** IAtom h = null; for (int k = 0; k < 4; k++) { ! if (container.getBond(a, container.getConnectedAtoms(a)[k]).getStereo() == CDKConstants.STEREO_BOND_UP) { up++; } ! if (container.getBond(a, container.getConnectedAtoms(a)[k]).getStereo() == CDKConstants.STEREO_BOND_DOWN) { down++; } ! if (container.getBond(a, container.getConnectedAtoms(a)[k]).getStereo() == CDKConstants.STEREO_BOND_NONE && container.getConnectedAtoms(a)[k].getSymbol().equals("H")) { ! h = container.getConnectedAtoms(a)[k]; hs++; } --- 867,878 ---- IAtom h = null; for (int k = 0; k < 4; k++) { ! if (container.getBond(a, (IAtom)container.getConnectedAtomsList(a).get(k)).getStereo() == CDKConstants.STEREO_BOND_UP) { up++; } ! if (container.getBond(a, (IAtom)container.getConnectedAtomsList(a).get(k)).getStereo() == CDKConstants.STEREO_BOND_DOWN) { down++; } ! if (container.getBond(a, (IAtom)container.getConnectedAtomsList(a).get(k)).getStereo() == CDKConstants.STEREO_BOND_NONE && ((IAtom)container.getConnectedAtomsList(a).get(k)).getSymbol().equals("H")) { ! h = (IAtom)container.getConnectedAtomsList(a).get(k); hs++; } *************** *** 897,916 **** */ public static IMolecule rearangeAtoms(IMolecule mol) throws Exception { ! IAtom[] atomsold = mol.getAtoms(); ! IAtom[] atomsnew = new IAtom[atomsold.length]; int k = 0; ! for (int i = 0; i < atomsold.length; i++) { ! if (atomsold[i].getSymbol().equals("C")) { ! atomsnew[k++] = atomsold[i]; ! } ! } ! for (int i = 0; i < atomsold.length; i++) { ! if (!atomsold[i].getSymbol().equals("C") && !atomsold[i].getSymbol().equals("H")) { ! atomsnew[k++] = atomsold[i]; ! } ! } ! for (int i = 0; i < atomsold.length; i++) { ! if (atomsold[i].getSymbol().equals("H")) { ! atomsnew[k++] = atomsold[i]; } } --- 899,923 ---- */ public static IMolecule rearangeAtoms(IMolecule mol) throws Exception { ! Iterator atomsold = mol.atoms(); ! IAtom[] atomsnew = new IAtom[mol.getAtomCount()]; int k = 0; ! while(atomsold.hasNext()) { ! IAtom atom=(IAtom)atomsold.next(); ! if (atom.getSymbol().equals("C")) { ! atomsnew[k++] = atom; ! } ! } ! atomsold = mol.atoms(); ! while(atomsold.hasNext()) { ! IAtom atom=(IAtom)atomsold.next(); ! if (!atom.getSymbol().equals("C") && !atom.getSymbol().equals("H")) { ! atomsnew[k++] = atom; ! } ! } ! atomsold = mol.atoms(); ! while(atomsold.hasNext()) { ! IAtom atom=(IAtom)atomsold.next(); ! if (atom.getSymbol().equals("H")) { ! atomsnew[k++] = atom; } } *************** *** 931,938 **** alreadyTouched++; atom.setFlag(CDKConstants.VISITED, true); ! IAtom[] connectedAtoms = mol.getConnectedAtoms(atom); boolean allConnectedAtomsAlreadTouched = true; ! for (int i = 0; i < connectedAtoms.length; i++) { ! if (connectedAtoms[i].getFlag(CDKConstants.VISITED) == false) { allConnectedAtomsAlreadTouched = false; } --- 938,945 ---- alreadyTouched++; atom.setFlag(CDKConstants.VISITED, true); ! List connectedAtoms = mol.getConnectedAtomsList(atom); boolean allConnectedAtomsAlreadTouched = true; ! for (int i = 0; i < connectedAtoms.size(); i++) { ! if (((IAtom)connectedAtoms.get(i)).getFlag(CDKConstants.VISITED) == false) { allConnectedAtomsAlreadTouched = false; } *************** *** 941,947 **** return (alreadyTouched); } ! for (int i = 0; i < connectedAtoms.length; i++) { ! if (!connectedAtoms[i].getFlag(CDKConstants.VISITED)) { ! alreadyTouched = setThisAtomAsLinked(connectedAtoms[i], mol, alreadyTouched); } } --- 948,954 ---- return (alreadyTouched); } ! for (int i = 0; i < connectedAtoms.size(); i++) { ! if (!((IAtom)connectedAtoms.get(i)).getFlag(CDKConstants.VISITED)) { ! alreadyTouched = setThisAtomAsLinked(((IAtom)connectedAtoms.get(i)), mol, alreadyTouched); } } Index: GeneralUtils.java =================================================================== RCS file: /cvsroot/nmrshiftdb/nmrshiftdb/src/java/org/openscience/nmrshiftdb/util/GeneralUtils.java,v retrieving revision 1.187 retrieving revision 1.188 diff -C2 -r1.187 -r1.188 *** GeneralUtils.java 23 Sep 2006 22:10:44 -0000 1.187 --- GeneralUtils.java 9 Oct 2006 13:24:38 -0000 1.188 *************** *** 746,754 **** IMolecule cdkmolwithh = mol.getAsCDKMolecule(1); IMolecule cdkmolwithouth = (IMolecule) AtomContainerManipulator.removeHydrogens(cdkmolwithh); ! IAtom[] atoms = cdkmolwithh.getAtoms(); DBAtom[] dbatoms = mol.getAtomsAsArrayInMdlOrder(); ! for (int i = 0; i < atoms.length; i++) { ! if (atoms[i].getSymbol().equals("C")) { ! String hc = hcg.getHOSECode(cdkmolwithouth, atoms[i], 1,true); StringTokenizer st = new StringTokenizer(hc, ";"); st.nextToken(); --- 746,756 ---- IMolecule cdkmolwithh = mol.getAsCDKMolecule(1); IMolecule cdkmolwithouth = (IMolecule) AtomContainerManipulator.removeHydrogens(cdkmolwithh); ! Iterator atoms = cdkmolwithh.atoms(); DBAtom[] dbatoms = mol.getAtomsAsArrayInMdlOrder(); ! int i=0; ! while(atoms.hasNext()){ ! IAtom atom=(IAtom)atoms.next(); ! if (atom.getSymbol().equals("C")) { ! String hc = hcg.getHOSECode(cdkmolwithouth, atom, 1,true); StringTokenizer st = new StringTokenizer(hc, ";"); st.nextToken(); *************** *** 770,773 **** --- 772,776 ---- } } + i++; } } *************** *** 2042,2046 **** return; } ! IMolecule mol = chemModel.getSetOfMolecules().getMolecule(0); data.getSession().setAttribute(attributename, mol); } --- 2045,2049 ---- return; } ! IMolecule mol = chemModel.getMoleculeSet().getMolecule(0); data.getSession().setAttribute(attributename, mol); } *************** *** 2098,2102 **** throw new NmrshiftdbException("Model does not have coordinates. Cannot open file"); } ! IMolecule mol = chemModel.getSetOfMolecules().getMolecule(0); StringWriter sw = new StringWriter(); new MDLWriter(sw).writeMolecule(mol); --- 2101,2105 ---- throw new NmrshiftdbException("Model does not have coordinates. Cannot open file"); } ! IMolecule mol = chemModel.getMoleculeSet().getMolecule(0); StringWriter sw = new StringWriter(); new MDLWriter(sw).writeMolecule(mol); Index: SubmittingData.java =================================================================== RCS file: /cvsroot/nmrshiftdb/nmrshiftdb/src/java/org/openscience/nmrshiftdb/util/SubmittingData.java,v retrieving revision 1.282 retrieving revision 1.283 diff -C2 -r1.282 -r1.283 *** SubmittingData.java 15 Sep 2006 12:08:33 -0000 1.282 --- SubmittingData.java 9 Oct 2006 13:24:38 -0000 1.283 *************** *** 890,894 **** IAtom mainAtom = null; if (choosenSpectrumType.getName().equals("1H")) { ! mainAtom = molWithH.getConnectedAtoms((IAtom) it.atoms.get(k))[0]; } else { mainAtom = (IAtom) it.atoms.get(k); --- 890,894 ---- IAtom mainAtom = null; if (choosenSpectrumType.getName().equals("1H")) { ! mainAtom = (IAtom)molWithH.getConnectedAtomsList((IAtom) it.atoms.get(k)).get(0); } else { mainAtom = (IAtom) it.atoms.get(k); *************** *** 1332,1336 **** break; } ! IAtom[] atoms = getMolWithH().getConnectedAtoms(molWithH.getAtom(((Float) ((ValueTriple) getSignalstable().get(i)).atoms.get(n)).intValue())); float numberToReplace = ((Float) ((ValueTriple) getSignalstable().get(i)).atoms.get(n)).floatValue(); IAtom atom = getMolWithH().getAtom((int) numberToReplace); --- 1332,1336 ---- break; } ! List atoms = getMolWithH().getConnectedAtomsList(molWithH.getAtom(((Float) ((ValueTriple) getSignalstable().get(i)).atoms.get(n)).intValue())); float numberToReplace = ((Float) ((ValueTriple) getSignalstable().get(i)).atoms.get(n)).floatValue(); IAtom atom = getMolWithH().getAtom((int) numberToReplace); *************** *** 1340,1349 **** if ((int) numberToReplace == numberToReplace) { boolean alreadyReplaced = false; ! for (int k = 0; k < atoms.length; k++) { ! if (atoms[k].getSymbol().equals("H")) { if (!alreadyReplaced) { ! ((ValueTriple) getSignalstable().get(i)).atoms.set(n, atoms[k]); } else { ! ((ValueTriple) getSignalstable().get(i)).atoms.add(atoms[k]); } } --- 1340,1349 ---- if ((int) numberToReplace == numberToReplace) { boolean alreadyReplaced = false; ! for (int k = 0; k < atoms.size(); k++) { ! if (((IAtom)atoms.get(k)).getSymbol().equals("H")) { if (!alreadyReplaced) { ! ((ValueTriple) getSignalstable().get(i)).atoms.set(n, ((IAtom)atoms.get(k))); } else { ! ((ValueTriple) getSignalstable().get(i)).atoms.add(((IAtom)atoms.get(k))); } } *************** *** 1352,1361 **** IAtom firstAtom = null; IAtom secondAtom = null; ! for (int k = 0; k < atoms.length; k++) { ! if (atoms[k].getSymbol().equals("H")) { if (firstAtom == null) { ! firstAtom = atoms[k]; } else { ! secondAtom = atoms[k]; break; } --- 1352,1361 ---- IAtom firstAtom = null; IAtom secondAtom = null; ! for (int k = 0; k < atoms.size(); k++) { ! if (((IAtom)atoms.get(k)).getSymbol().equals("H")) { if (firstAtom == null) { ! firstAtom = ((IAtom)atoms.get(k)); } else { ! secondAtom = ((IAtom)atoms.get(k)); break; } *************** *** 1450,1462 **** * @return The atomNumber value */ ! private int getAtomNumber(IAtom atom, IAtomContainer ac) { ! IAtom[] atoms = ac.getAtoms(); ! for (int i = 0; i < atoms.length; i++) { ! if (atoms[i].getPoint2d()!=null && atoms[i].getPoint2d().equals(atom.getPoint2d())) { return (i); } ! if (atoms[i].getPoint3d()!=null && atoms[i].getPoint3d().equals(atom.getPoint3d())) { ! return (i); ! } } return (-1); --- 1450,1465 ---- * @return The atomNumber value */ ! private int getAtomNumber(IAtom atomcompare, IAtomContainer ac) { ! Iterator atoms = ac.atoms(); ! int i=0; ! while(atoms.hasNext()){ ! IAtom atom=(IAtom)atoms.next(); ! if (atom.getPoint2d()!=null && atom.getPoint2d().equals(atom.getPoint2d())) { return (i); } ! if (atom.getPoint3d()!=null && atom.getPoint3d().equals(atomcompare.getPoint3d())) { ! return (i); ! } ! i++; } return (-1); *************** *** 1533,1557 **** Log.debug("after insert chemName"); //Add atoms to db ! IAtom[] atoms = molWithH.getAtoms(); ! dbatoms = new NumberKey[atoms.length]; HOSECodeGenerator hcg = new HOSECodeGenerator(); ! for (int i = 0; i < atoms.length; i++) { String hoseCode = null; String hoseCodeWithRings = null; ! if (GeneralUtils.getAtomsWithHoseCode().contains(atoms[i].getSymbol())) { int l = i; for (int k = 0; k < i; k++) { ! if (atoms[k].getSymbol().equals("H")) { l--; } } ! hoseCode = hcg.getHOSECode(molWithHCount, molWithHCount.getAtoms()[l], numberOfSpheres,false); ! hoseCodeWithRings = hcg.getHOSECode(molWithHCount, molWithHCount.getAtoms()[l], numberOfSpheres,true); } ! if( atoms[i].getSymbol().equals("H")){ ! hoseCode = hcg.getHOSECode(molWithH, molWithH.getAtoms()[i], numberOfSpheres,false); ! hoseCodeWithRings = hcg.getHOSECode(molWithH, molWithH.getAtoms()[i], numberOfSpheres,true); } ! DBAtom atom = new DBAtom(atoms[i], molWithH, dbmol, hoseCode, hoseCodeWithRings, i < numberOfAtomsInMdl); //atom.force3d=true; atom.save(dbconn); --- 1536,1560 ---- Log.debug("after insert chemName"); //Add atoms to db ! Iterator atoms = molWithH.atoms(); ! dbatoms = new NumberKey[molWithH.getAtomCount()]; HOSECodeGenerator hcg = new HOSECodeGenerator(); ! for (int i = 0; i < molWithH.getAtomCount(); i++) { String hoseCode = null; String hoseCodeWithRings = null; ! if (GeneralUtils.getAtomsWithHoseCode().contains(molWithH.getAtom(i).getSymbol())) { int l = i; for (int k = 0; k < i; k++) { ! if (molWithH.getAtom(k).getSymbol().equals("H")) { l--; } } ! hoseCode = hcg.getHOSECode(molWithHCount, molWithHCount.getAtom(l), numberOfSpheres,false); ! hoseCodeWithRings = hcg.getHOSECode(molWithHCount, molWithHCount.getAtom(l), numberOfSpheres,true); } ! if(molWithH.getAtom(i).getSymbol().equals("H")){ ! hoseCode = hcg.getHOSECode(molWithH, molWithH.getAtom(i), numberOfSpheres,false); ! hoseCodeWithRings = hcg.getHOSECode(molWithH, molWithH.getAtom(i), numberOfSpheres,true); } ! DBAtom atom = new DBAtom(molWithH.getAtom(i), molWithH, dbmol, hoseCode, hoseCodeWithRings, i < numberOfAtomsInMdl); //atom.force3d=true; atom.save(dbconn); *************** *** 1565,1575 **** bond.save(dbconn); //Add bonds-atoms relationship to DB ! IAtom[] neighbourAtoms = bonds[i].getAtoms(); ! for (int k = 0; k < neighbourAtoms.length; k++) { DBBondDBAtom bondatom = new DBBondDBAtom(); ! bondatom.setAtomId(dbatoms[molWithH.getAtomNumber(neighbourAtoms[k])]); bondatom.setBondId(bond.getBondId()); bondatom.setOrderNumber(k); bondatom.save(dbconn); } } --- 1568,1580 ---- bond.save(dbconn); //Add bonds-atoms relationship to DB ! Iterator neighbourAtoms = bonds[i].atoms(); ! int k=0; ! while(neighbourAtoms.hasNext()){ DBBondDBAtom bondatom = new DBBondDBAtom(); ! bondatom.setAtomId(dbatoms[molWithH.getAtomNumber((IAtom)neighbourAtoms.next())]); bondatom.setBondId(bond.getBondId()); bondatom.setOrderNumber(k); bondatom.save(dbconn); + k++; } } |