From: <eg...@us...> - 2007-11-13 15:40:26
|
Revision: 9427 http://cdk.svn.sourceforge.net/cdk/?rev=9427&view=rev Author: egonw Date: 2007-11-13 07:40:21 -0800 (Tue, 13 Nov 2007) Log Message: ----------- Synched with trunk up to rev 9426 Revision Links: -------------- http://cdk.svn.sourceforge.net/cdk/?rev=9426&view=rev Modified Paths: -------------- branches/egonw/remove-non-cdkatomtype-code/src/data/smiles/drugs.smi branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/qsar/descriptors/molecular/AromaticBondsCountDescriptor.java branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/qsar/descriptors/molecular/PetitjeanNumberDescriptor.java branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/qsar/descriptors/molecular/XLogPDescriptor.java branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/io/MDLReaderTest.java branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/qsar/descriptors/molecular/AromaticBondsCountDescriptorTest.java branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/qsar/descriptors/molecular/PetitjeanNumberDescriptorTest.java branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/smiles/smarts/parser/RecursiveTest.java branches/egonw/remove-non-cdkatomtype-code/tools/nightly.py Added Paths: ----------- branches/egonw/remove-non-cdkatomtype-code/src/data/mdl/hisotopes.mol Copied: branches/egonw/remove-non-cdkatomtype-code/src/data/mdl/hisotopes.mol (from rev 9425, trunk/cdk/src/data/mdl/hisotopes.mol) =================================================================== --- branches/egonw/remove-non-cdkatomtype-code/src/data/mdl/hisotopes.mol (rev 0) +++ branches/egonw/remove-non-cdkatomtype-code/src/data/mdl/hisotopes.mol 2007-11-13 15:40:21 UTC (rev 9427) @@ -0,0 +1,11 @@ +24602 + -OEChem-11060703412D + + 3 2 0 0 0 0 0 0 0 0999 V2000 + 2.5369 -0.1550 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 + 3.0739 0.1550 0.0000 D 1 0 0 0 0 0 0 0 0 0 0 0 + 2.0000 0.1550 0.0000 T 1 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 0 0 0 + 1 3 1 0 0 0 0 +M ISO 2 2 2 3 2 +M END \ No newline at end of file Modified: branches/egonw/remove-non-cdkatomtype-code/src/data/smiles/drugs.smi =================================================================== --- branches/egonw/remove-non-cdkatomtype-code/src/data/smiles/drugs.smi 2007-11-13 15:33:53 UTC (rev 9426) +++ branches/egonw/remove-non-cdkatomtype-code/src/data/smiles/drugs.smi 2007-11-13 15:40:21 UTC (rev 9427) @@ -136,7 +136,6 @@ c1ccc2c(c1)[nH]c(=O)n2C1=CCN(CC1)CCCC(=O)c1ccc(cc1)F 3168 c1ccc2c(c1)[nH]c(=O)n2C1CCN(CC1)CCCC(c1ccc(cc1)F)c1ccc(cc1)F 16362 c1ccc2c(c1)[nH]c(=O)n2CCCN1CCC(CC1)n1c2ccc(cc2[nH]c1=O)Cl 3151 -c1ccc2c(c1)[nH]c(n2)c1c[s]c[nH]1 5430 c1ccc2c(c1)c(=O)[nH]c1cccnc1n2C(=O)CN1CCN(CC1)C 4848 c1cnc(cn1)C(=O)N 1046 c1nc2c([nH]1)c(=O)n(c(=O)n2C)C 2153 Modified: branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java =================================================================== --- branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java 2007-11-13 15:33:53 UTC (rev 9426) +++ branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java 2007-11-13 15:40:21 UTC (rev 9427) @@ -91,25 +91,25 @@ if (atom.getHybridization() != CDKConstants.UNSET && (atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0)) { if (atom.getHybridization() == Hybridization.SP2) { - return factory.getAtomType("C.sp2"); + return getAtomType("C.sp2"); } else if (atom.getHybridization() == Hybridization.SP3) { - return factory.getAtomType("C.sp3"); + return getAtomType("C.sp3"); } else if (atom.getHybridization() == Hybridization.SP1) { - return factory.getAtomType("C.sp"); + return getAtomType("C.sp"); } } else if (atom.getFlag(CDKConstants.ISAROMATIC)) { - return factory.getAtomType("C.sp2"); + return getAtomType("C.sp2"); } else if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() != 0) { if (atom.getFormalCharge() == 1) { if (atomContainer.getConnectedBondsCount(atom) == 0) { - return factory.getAtomType("C.plus.sp2"); + return getAtomType("C.plus.sp2"); } else { double maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { - return factory.getAtomType("C.plus.sp2"); + return getAtomType("C.plus.sp2"); } else if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { - return factory.getAtomType("C.plus.planar"); + return getAtomType("C.plus.planar"); } } } else if (atom.getFormalCharge() == -1) { @@ -129,15 +129,15 @@ } } } - if (bothNeighborsSP2) return factory.getAtomType("C.minus.planar"); + if (bothNeighborsSP2) return getAtomType("C.minus.planar"); } - return factory.getAtomType("C.minus.sp3"); + return getAtomType("C.minus.sp3"); } else if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE && atomContainer.getConnectedBondsCount(atom) <= 3) { - return factory.getAtomType("C.minus.sp2"); + return getAtomType("C.minus.sp2"); } else if (maxBondOrder == CDKConstants.BONDORDER_TRIPLE && atomContainer.getConnectedBondsCount(atom) <= 1) { - return factory.getAtomType("C.minus.sp1"); + return getAtomType("C.minus.sp1"); } } return null; @@ -150,7 +150,7 @@ // WTF?? return null; } else if (maxBondOrder == CDKConstants.BONDORDER_TRIPLE) { - return factory.getAtomType("C.sp"); + return getAtomType("C.sp"); } else if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { // OK, one or two double bonds? Iterator<IBond> bonds = atomContainer.getConnectedBondsList(atom).iterator(); @@ -160,12 +160,12 @@ doubleBondCount++; } if (doubleBondCount == 2) { - return factory.getAtomType("C.sp"); + return getAtomType("C.sp"); } else if (doubleBondCount == 1) { - return factory.getAtomType("C.sp2"); + return getAtomType("C.sp2"); } } else { - return factory.getAtomType("C.sp3"); + return getAtomType("C.sp3"); } } } @@ -182,32 +182,32 @@ if (atom.getHybridization() == Hybridization.SP2) { double maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { - return factory.getAtomType("O.sp2"); + return getAtomType("O.sp2"); } else if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { - return factory.getAtomType("O.planar3"); + return getAtomType("O.planar3"); } } else if (atom.getHybridization() == Hybridization.SP3) { - return factory.getAtomType("O.sp3"); + return getAtomType("O.sp3"); } else if (atom.getHybridization() == Hybridization.PLANAR3) { - return factory.getAtomType("O.planar3"); + return getAtomType("O.planar3"); } } else if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() != 0) { if (atom.getFormalCharge() == -1 && atomContainer.getConnectedAtomsCount(atom) <= 1) { - return factory.getAtomType("O.minus"); + return getAtomType("O.minus"); } else if (atom.getFormalCharge() == -2 && atomContainer.getConnectedAtomsCount(atom) == 0) { - return factory.getAtomType("O.minus2"); + return getAtomType("O.minus2"); } else if (atom.getFormalCharge() == +1) { if (atomContainer.getConnectedBondsCount(atom) == 0) { - return factory.getAtomType("O.plus"); + return getAtomType("O.plus"); } double maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { - return factory.getAtomType("O.plus.sp2"); + return getAtomType("O.plus.sp2"); } else { - return factory.getAtomType("O.plus"); + return getAtomType("O.plus"); } } return null; @@ -217,18 +217,18 @@ } else { // OK, use bond order info double maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { - return factory.getAtomType("O.sp2"); + return getAtomType("O.sp2"); } else if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { int explicitHydrogens = countExplicitHydrogens(atom, atomContainer); int connectedHeavyAtoms = atomContainer.getConnectedBondsCount(atom) - explicitHydrogens; if (connectedHeavyAtoms == 2) { // a O.sp3 which is expected to take part in an aromatic system if (isRingAtom(atom, atomContainer) && bothNeighborsAreSp2(atom, atomContainer)) { - return factory.getAtomType("O.planar3"); + return getAtomType("O.planar3"); } - return factory.getAtomType("O.sp3"); + return getAtomType("O.sp3"); } else { - return factory.getAtomType("O.sp3"); + return getAtomType("O.sp3"); } } } @@ -263,16 +263,16 @@ (atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0)) { if (atom.getHybridization() == Hybridization.SP1) { - return factory.getAtomType("N.sp1"); + return getAtomType("N.sp1"); } else if (atom.getHybridization() == Hybridization.SP2) { // but an sp2 hyb N might N.sp2 or N.planar3 (pyrrole), so check for the latter int hcount = atom.getHydrogenCount() == null ? 0 : atom.getHydrogenCount(); if (isRingAtom(atom, atomContainer) && atomContainer.getConnectedAtomsCount(atom) + hcount == 3 && - bothNeighborsAreSp2(atom, atomContainer)) return factory.getAtomType("N.planar3"); - return factory.getAtomType("N.sp2"); + bothNeighborsAreSp2(atom, atomContainer)) return getAtomType("N.planar3"); + return getAtomType("N.sp2"); } else if (atom.getHybridization() == Hybridization.SP3) { - return factory.getAtomType("N.sp3"); + return getAtomType("N.sp3"); } } else if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() != 0) { @@ -280,28 +280,28 @@ double maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_SINGLE || atomContainer.getConnectedBondsCount(atom) == 0) { - return factory.getAtomType("N.plus"); + return getAtomType("N.plus"); } else if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { int doubleBonds= countAttachedDoubleBonds(atomContainer, atom); if (doubleBonds == 1) { - return factory.getAtomType("N.plus.sp2"); + return getAtomType("N.plus.sp2"); } else if (doubleBonds == 2) { - return factory.getAtomType("N.plus.sp1"); + return getAtomType("N.plus.sp1"); } } else if (maxBondOrder == CDKConstants.BONDORDER_TRIPLE) { if (atomContainer.getConnectedBondsCount(atom) == 2) { - return factory.getAtomType("N.plus.sp1"); + return getAtomType("N.plus.sp1"); } } } else if (atom.getFormalCharge() == -1) { double maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { if (atomContainer.getConnectedBondsCount(atom) <= 2) { - return factory.getAtomType("N.minus.sp3"); + return getAtomType("N.minus.sp3"); } } else if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { if (atomContainer.getConnectedBondsCount(atom) <= 1) { - return factory.getAtomType("N.minus.sp2"); + return getAtomType("N.minus.sp2"); } } } @@ -309,7 +309,7 @@ // FIXME: I don't perceive carbons with more than 3 connections yet return null; } else if (atomContainer.getConnectedBondsCount(atom) == 0) { - return factory.getAtomType("N.sp3"); + return getAtomType("N.sp3"); } else { // OK, use bond order info double maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { @@ -317,33 +317,33 @@ int connectedHeavyAtoms = atomContainer.getConnectedBondsCount(atom) - explicitHydrogens; if (connectedHeavyAtoms == 2) { if (isAmide(atom, atomContainer)) { - return factory.getAtomType("N.amide"); + return getAtomType("N.amide"); } List<IBond> bonds = atomContainer.getConnectedBondsList(atom); if (bonds.get(0).getFlag(CDKConstants.ISAROMATIC) && bonds.get(1).getFlag(CDKConstants.ISAROMATIC)) { - return factory.getAtomType("N.sp2"); + return getAtomType("N.sp2"); } else { // a N.sp3 which is expected to take part in an aromatic system if (isRingAtom(atom, atomContainer) && bothNeighborsAreSp2(atom, atomContainer)) { - return factory.getAtomType("N.planar3"); + return getAtomType("N.planar3"); } - return factory.getAtomType("N.sp3"); + return getAtomType("N.sp3"); } } else if (connectedHeavyAtoms == 3) { - return factory.getAtomType("N.sp3"); + return getAtomType("N.sp3"); } else if (connectedHeavyAtoms == 1) { if (isAmide(atom, atomContainer)) { - return factory.getAtomType("N.amide"); + return getAtomType("N.amide"); } - return factory.getAtomType("N.sp3"); + return getAtomType("N.sp3"); } else if (connectedHeavyAtoms == 0) { - return factory.getAtomType("N.sp3"); + return getAtomType("N.sp3"); } } else if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { - return factory.getAtomType("N.sp2"); + return getAtomType("N.sp2"); } else if (maxBondOrder == CDKConstants.BONDORDER_TRIPLE) { - return factory.getAtomType("N.sp1"); + return getAtomType("N.sp1"); } } } @@ -390,12 +390,12 @@ atom.getFormalCharge() != 0) { if (atom.getFormalCharge() == -1 && neighborcount == 1) { - return factory.getAtomType("S.minus"); + return getAtomType("S.minus"); } } else if (neighborcount == 6) { double maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { - return factory.getAtomType("S.octahedral"); + return getAtomType("S.octahedral"); } } else if (neighborcount == 2) { if (isRingAtom(atom, atomContainer)) { @@ -411,26 +411,26 @@ } } } - if (bothNeighborsSP2) return factory.getAtomType("S.planar3"); + if (bothNeighborsSP2) return getAtomType("S.planar3"); } - return factory.getAtomType("S.3"); + return getAtomType("S.3"); } else if (neighborcount == 1) { if (atomContainer.getConnectedBondsList(atom).get(0).getOrder() == CDKConstants.BONDORDER_DOUBLE) { - return factory.getAtomType("S.2"); + return getAtomType("S.2"); } else { - return factory.getAtomType("S.3"); + return getAtomType("S.3"); } } else if (neighborcount == 0) { - return factory.getAtomType("S.3"); + return getAtomType("S.3"); } else { // count the number of double bonded oxygens int doubleBondedOxygens = countAttachedDoubleBonds(atomContainer, atom, "O"); int doubleBondedNitrogens = countAttachedDoubleBonds(atomContainer, atom, "N"); if (doubleBondedOxygens + doubleBondedNitrogens == 2 && neighborcount == 4){ - return factory.getAtomType("S.onyl"); + return getAtomType("S.onyl"); } else if (doubleBondedOxygens == 1 && neighborcount == 3){ - return factory.getAtomType("S.inyl"); + return getAtomType("S.inyl"); }; } } @@ -444,12 +444,12 @@ int neighborcount = neighbors.size(); double maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (neighborcount == 3) { - return factory.getAtomType("P.ine"); + return getAtomType("P.ine"); } else if (neighborcount == 2) { if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { - return factory.getAtomType("P.ine"); + return getAtomType("P.ine"); } else if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { - return factory.getAtomType("P.ine"); + return getAtomType("P.ine"); } } else if (neighborcount == 4) { // count the number of double bonded oxygens @@ -460,7 +460,7 @@ } } if (doubleBonds == 1){ - return factory.getAtomType("P.ate"); + return getAtomType("P.ate"); }; } } @@ -475,15 +475,15 @@ return null; } else if (neighborcount == 1) { if (atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0) { - return factory.getAtomType("H"); + return getAtomType("H"); } } else if (neighborcount == 0) { if (atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0) { - return factory.getAtomType("H"); + return getAtomType("H"); } else if (atom.getFormalCharge() == 1){ - return factory.getAtomType("H.plus"); + return getAtomType("H.plus"); } else if (atom.getFormalCharge() == -1){ - return factory.getAtomType("H.minus"); + return getAtomType("H.minus"); } } } @@ -495,47 +495,47 @@ if ("Cl".equals(atom.getSymbol())) { if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == -1)) { - return factory.getAtomType("Cl.minus"); + return getAtomType("Cl.minus"); } else if (atomContainer.getConnectedBondsCount(atom) == 1 || atomContainer.getConnectedBondsCount(atom) == 0) { - return factory.getAtomType("Cl"); + return getAtomType("Cl"); } else { int doubleBonds = countAttachedDoubleBonds(atomContainer, atom); if (atomContainer.getConnectedBondsCount(atom) == 3 && doubleBonds == 2) { - return factory.getAtomType("Cl.chlorate"); + return getAtomType("Cl.chlorate"); } else if (atomContainer.getConnectedBondsCount(atom) == 4 && doubleBonds == 3) { - return factory.getAtomType("Cl.perchlorate"); + return getAtomType("Cl.perchlorate"); } } } else if ("Br".equals(atom.getSymbol())) { if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == -1)) { - return factory.getAtomType("Br.minus"); + return getAtomType("Br.minus"); } else if (atomContainer.getConnectedBondsCount(atom) == 1 || atomContainer.getConnectedBondsCount(atom) == 0) { - return factory.getAtomType("Br"); + return getAtomType("Br"); } } else if ("F".equals(atom.getSymbol())) { if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == -1)) { - return factory.getAtomType("F.minus"); + return getAtomType("F.minus"); } else if (atomContainer.getConnectedBondsCount(atom) == 1 || atomContainer.getConnectedBondsCount(atom) == 0) { - return factory.getAtomType("F"); + return getAtomType("F"); } } else if ("I".equals(atom.getSymbol())) { if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() != 0) { if (atom.getFormalCharge() == -1) { - return factory.getAtomType("I.minus"); + return getAtomType("I.minus"); } else if (atom.getFormalCharge() == 1) { - return factory.getAtomType("I.plus"); + return getAtomType("I.plus"); } } else if (atomContainer.getConnectedBondsCount(atom) == 1 || atomContainer.getConnectedBondsCount(atom) == 0) { - return factory.getAtomType("I"); + return getAtomType("I"); } } return null; @@ -545,32 +545,32 @@ if ("Na".equals(atom.getSymbol())) { if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +1)) { - return factory.getAtomType("Na.plus"); + return getAtomType("Na.plus"); } } else if ("Ca".equals(atom.getSymbol())) { if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +2)) { - return factory.getAtomType("Ca.2plus"); + return getAtomType("Ca.2plus"); } } else if ("Mg".equals(atom.getSymbol())) { if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +2)) { - return factory.getAtomType("Mg.2plus"); + return getAtomType("Mg.2plus"); } } else if ("Fe".equals(atom.getSymbol())) { if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +2)) { - return factory.getAtomType("Fe.2plus"); + return getAtomType("Fe.2plus"); } } else if ("Ni".equals(atom.getSymbol())) { if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +2)) { - return factory.getAtomType("Ni.2plus"); + return getAtomType("Ni.2plus"); } } else if ("K".equals(atom.getSymbol())) { if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +1)) { - return factory.getAtomType("K.plus"); + return getAtomType("K.plus"); } } return null; @@ -580,11 +580,11 @@ if ("Hg".equals(atom.getSymbol())) { if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == -1)) { - return factory.getAtomType("Hg.minus"); + return getAtomType("Hg.minus"); } } else if ("Po".equals(atom.getSymbol())) { if (atomContainer.getConnectedBondsCount(atom) == 2) { - return factory.getAtomType("Po"); + return getAtomType("Po"); } } return null; @@ -594,7 +594,7 @@ if ("He".equals(atom.getSymbol())) { if ((atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0)) { - return factory.getAtomType("He"); + return getAtomType("He"); } } return null; @@ -605,7 +605,7 @@ if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == 0 && atomContainer.getConnectedBondsCount(atom) <= 4)) { - return factory.getAtomType("Si.sp3"); + return getAtomType("Si.sp3"); } } return null; @@ -645,5 +645,12 @@ return doubleBondedAtoms; } + private IAtomType getAtomType(String identifier) throws CDKException { + IAtomType type = factory.getAtomType(identifier); + type.setValency((Integer)type.getProperty(CDKConstants.PI_BOND_COUNT) + + type.getFormalNeighbourCount()); + return type; + } + } Modified: branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/qsar/descriptors/molecular/AromaticBondsCountDescriptor.java =================================================================== --- branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/qsar/descriptors/molecular/AromaticBondsCountDescriptor.java 2007-11-13 15:33:53 UTC (rev 9426) +++ branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/qsar/descriptors/molecular/AromaticBondsCountDescriptor.java 2007-11-13 15:40:21 UTC (rev 9427) @@ -116,7 +116,7 @@ throw new CDKException("The first parameter must be of type Boolean"); } // ok, all should be fine - checkAromaticity = ((Boolean) params[0]).booleanValue(); + checkAromaticity = (Boolean) params[0]; } @@ -129,7 +129,7 @@ public Object[] getParameters() { // return the parameters as used for the descriptor calculation Object[] params = new Object[1]; - params[0] = new Boolean(checkAromaticity); + params[0] = checkAromaticity; return params; } @@ -206,7 +206,7 @@ *@return An Object of class equal to that of the parameter being requested */ public Object getParameterType(String name) { - return new Boolean(true); + return true; } } Modified: branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/qsar/descriptors/molecular/PetitjeanNumberDescriptor.java =================================================================== --- branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/qsar/descriptors/molecular/PetitjeanNumberDescriptor.java 2007-11-13 15:33:53 UTC (rev 9426) +++ branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/qsar/descriptors/molecular/PetitjeanNumberDescriptor.java 2007-11-13 15:40:21 UTC (rev 9427) @@ -119,12 +119,12 @@ *@exception CDKException Possible Exceptions */ public DescriptorValue calculate(IAtomContainer atomContainer) throws CDKException { - double petitjeanNumber = 0; //weinerPath + double petitjeanNumber; //weinerPath int diameter = PathTools.getMolecularGraphDiameter(atomContainer); int radius = PathTools.getMolecularGraphRadius(atomContainer); if (diameter == 0) petitjeanNumber = 0; - else petitjeanNumber = (diameter - radius)/diameter; + else petitjeanNumber = (diameter - radius)/(double)diameter; return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(petitjeanNumber), new String[] {"PetitjeanNumber"}); } Modified: branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/qsar/descriptors/molecular/XLogPDescriptor.java =================================================================== --- branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/qsar/descriptors/molecular/XLogPDescriptor.java 2007-11-13 15:33:53 UTC (rev 9426) +++ branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/qsar/descriptors/molecular/XLogPDescriptor.java 2007-11-13 15:40:21 UTC (rev 9427) @@ -20,29 +20,16 @@ */ package org.openscience.cdk.qsar.descriptors.molecular; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import org._3pq.jgrapht.graph.SimpleGraph; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.aromaticity.CDKHueckelAromaticityDetector; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.graph.BFSShortestPath; import org.openscience.cdk.graph.MoleculeGraphs; -import org.openscience.cdk.interfaces.IAtom; -import org.openscience.cdk.interfaces.IAtomContainer; -import org.openscience.cdk.interfaces.IBond; -import org.openscience.cdk.interfaces.IChemObjectBuilder; -import org.openscience.cdk.interfaces.IRing; -import org.openscience.cdk.interfaces.IRingSet; +import org.openscience.cdk.interfaces.*; import org.openscience.cdk.interfaces.IAtomType.Hybridization; import org.openscience.cdk.isomorphism.UniversalIsomorphismTester; -import org.openscience.cdk.isomorphism.matchers.IQueryAtom; -import org.openscience.cdk.isomorphism.matchers.OrderQueryBond; -import org.openscience.cdk.isomorphism.matchers.QueryAtomContainer; -import org.openscience.cdk.isomorphism.matchers.QueryAtomContainerCreator; -import org.openscience.cdk.isomorphism.matchers.SymbolQueryAtom; +import org.openscience.cdk.isomorphism.matchers.*; import org.openscience.cdk.isomorphism.matchers.smarts.AnyOrderQueryBond; import org.openscience.cdk.isomorphism.matchers.smarts.AromaticAtom; import org.openscience.cdk.isomorphism.matchers.smarts.AromaticQueryBond; @@ -57,6 +44,10 @@ import org.openscience.cdk.tools.manipulator.AtomContainerManipulator; import org.openscience.cdk.tools.manipulator.RingSetManipulator; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + /** * <p>Prediction of logP based on the atom-type method called XLogP. <b>Requires * all hydrogens to be explicit</b>. Modified: branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/io/MDLReaderTest.java =================================================================== --- branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/io/MDLReaderTest.java 2007-11-13 15:33:53 UTC (rev 9426) +++ branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/io/MDLReaderTest.java 2007-11-13 15:40:21 UTC (rev 9427) @@ -35,6 +35,7 @@ import org.openscience.cdk.ChemModel; import org.openscience.cdk.ChemObject; import org.openscience.cdk.Molecule; +import org.openscience.cdk.PseudoAtom; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IMolecule; @@ -172,4 +173,18 @@ assertNull(mol); } + /** + * @cdk.bug 1826577 + */ + public void testHisotopes() throws Exception { + String filename = "data/mdl/hisotopes.mol"; + logger.info("Testing: " + filename); + InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); + MDLReader reader = new MDLReader(ins); + ChemFile chemFile = (ChemFile)reader.read((ChemObject)new ChemFile()); + assertNotNull(chemFile); + List containersList = ChemFileManipulator.getAllAtomContainers(chemFile); + assertFalse(((IAtomContainer)containersList.get(0)).getAtom(1) instanceof PseudoAtom); + assertFalse(((IAtomContainer)containersList.get(0)).getAtom(1) instanceof PseudoAtom); + } } Modified: branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/qsar/descriptors/molecular/AromaticBondsCountDescriptorTest.java =================================================================== --- branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/qsar/descriptors/molecular/AromaticBondsCountDescriptorTest.java 2007-11-13 15:33:53 UTC (rev 9426) +++ branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/qsar/descriptors/molecular/AromaticBondsCountDescriptorTest.java 2007-11-13 15:40:21 UTC (rev 9427) @@ -23,11 +23,8 @@ */ package org.openscience.cdk.test.qsar.descriptors.molecular; -import java.util.Iterator; - import junit.framework.Test; import junit.framework.TestSuite; - import org.openscience.cdk.CDKConstants; import org.openscience.cdk.DefaultChemObjectBuilder; import org.openscience.cdk.exception.CDKException; @@ -41,6 +38,8 @@ import org.openscience.cdk.templates.MoleculeFactory; import org.openscience.cdk.test.CDKTestCase; +import java.util.Iterator; + /** * TestSuite that runs all QSAR tests. * @@ -58,7 +57,7 @@ public void testAromaticBondsCountDescriptor() throws ClassNotFoundException, CDKException, java.lang.Exception { IMolecularDescriptor descriptor = new AromaticBondsCountDescriptor(); - Object[] params = {new Boolean(true)}; + Object[] params = {true}; descriptor.setParameters(params); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("CCOc1ccccc1"); // ethanol Modified: branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/qsar/descriptors/molecular/PetitjeanNumberDescriptorTest.java =================================================================== --- branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/qsar/descriptors/molecular/PetitjeanNumberDescriptorTest.java 2007-11-13 15:33:53 UTC (rev 9426) +++ branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/qsar/descriptors/molecular/PetitjeanNumberDescriptorTest.java 2007-11-13 15:40:21 UTC (rev 9427) @@ -50,7 +50,7 @@ return new TestSuite(PetitjeanNumberDescriptorTest.class); } - public void testPetitjeanNumberDescriptor() throws ClassNotFoundException, CDKException, java.lang.Exception { + public void testPetitjeanNumberDescriptor() throws java.lang.Exception { IMolecularDescriptor descriptor = new PetitjeanNumberDescriptor(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("O=C(O)CC"); Modified: branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/smiles/smarts/parser/RecursiveTest.java =================================================================== --- branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/smiles/smarts/parser/RecursiveTest.java 2007-11-13 15:33:53 UTC (rev 9426) +++ branches/egonw/remove-non-cdkatomtype-code/src/org/openscience/cdk/test/smiles/smarts/parser/RecursiveTest.java 2007-11-13 15:40:21 UTC (rev 9427) @@ -62,6 +62,7 @@ SMARTSQueryTool sqt = new SMARTSQueryTool(smarts, true); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer atomContainer = sp.parseSmiles(smiles); + CDKHueckelAromaticityDetector.detectAromaticity(atomContainer); boolean status = sqt.matches(atomContainer); if (status) { nmatch = sqt.countMatches(); @@ -263,30 +264,64 @@ match("[NX3;H2,H1;!$(NC=O)]", "Cc1nc2=NC3=C(C(n2[nH]1)c1cc(cc(c1)F)F)C(=O)CC(C3)c1ccco1"); assertEquals(1, nmatch); assertEquals(1, nqmatch); + } + public void testRecursiveSmarts34() throws Exception { + match("[NX3;h2,h1,H1,H2;!$(NC=O)]", "NC1CCCC1C(CCNC)Cc1ccccc1N"); + assertEquals(3, nmatch); + assertEquals(3, nqmatch); + } + + public void testRecursiveSmarts30() throws Exception { match("[NX3;H2,H1;!$(NC=O)]", "CC1CCCC(C1)N1CCN(CC1)C1CCN(CC1)Cc1ccccc1"); assertEquals(0, nmatch); assertEquals(0, nqmatch); + } + public void testRecursiveSmarts31() throws Exception { match("[NX3;H2,H1;!$(NC=O)]", "CCOc1cc2c(cc1/C=C/C(=O)c1ccc(cc1)S(=O)(=O)N1CCCC1)OC(C2)C"); assertEquals(0, nmatch); assertEquals(0, nqmatch); + } + public void testRecursiveSmarts32() throws Exception { match("[NX3;H2,H1;!$(NC=O)]", "CN1CCc2cc3c(c(c2C1CC(=O)/C=C/c1ccco1)OC)OCO3"); assertEquals(0, nmatch); assertEquals(0, nqmatch); + } - + public void testRecursiveSmarts33() throws Exception { match("[NX3;H2,H1;!$(NC=O)]", "Cc1nc2=NC3=C(C(n2[nH]1)c1cc(cc(c1)F)F)C(=O)CC(C3)c1ccco1"); assertEquals(1, nmatch); assertEquals(1, nqmatch); + } - match("[NX3;h2,h1,H1,H2;!$(NC=O)]", "NC1CCCC1C(CCNC)Cc1ccccc1N"); - assertEquals(3, nmatch); - assertEquals(3, nqmatch); + public void testRecursiveSmarts26() throws Exception { + match("[NX3;H2,H1;!$(NC=O)]", "CCCc1cc(=O)nc([nH]1)S"); + assertEquals(0, nmatch); + assertEquals(0, nqmatch); } + public void testRecursiveSmarts27() throws Exception { + match("[NX3;H2,H1;!$(NC=O)]", "CCCc1nc(c2n1[nH]c(nc2=O)c1cc(ccc1OCC)S(=O)(=O)N1CCN(CC1)CC)C"); + assertEquals(0, nmatch); + assertEquals(0, nqmatch); + } + + public void testRecursive28() throws Exception { + match("[NX3;H2,H1;!$(NC=O)]", "Cc1ccc[n+]2c1[nH]cc(c2=O)c1n[nH]nn1"); + assertEquals(0, nmatch); + assertEquals(0, nqmatch); + } + + public void testRecursive29() throws Exception { + match("[NX3;H2,H1;!$(NC=O)]", "Cc1cc(=O)c(c[nH]1)C(=O)NC(c1ccc(cc1)O)C(=O)NC1C(=O)N2C1SCC(=C2C(=O)O)CSc1nnnn1C"); + assertEquals(0, nmatch); + assertEquals(0, nqmatch); + } + + public void testBasicAmineOnDrugs() throws CDKException, IOException { String filename = "data/smiles/drugs.smi"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); Modified: branches/egonw/remove-non-cdkatomtype-code/tools/nightly.py =================================================================== --- branches/egonw/remove-non-cdkatomtype-code/tools/nightly.py 2007-11-13 15:33:53 UTC (rev 9426) +++ branches/egonw/remove-non-cdkatomtype-code/tools/nightly.py 2007-11-13 15:40:21 UTC (rev 9427) @@ -986,7 +986,28 @@ if not status: print "Error parsing build.props. Could not a valid version line. Exiting" sys.exit(-1) - + + # get a summary of the test results from the previous run + # we also get the old rev number for display purposes + reports = glob.glob(os.path.join(nightly_repo, 'reports', '*.txt')) + reports.sort() + oldReports = [] + for report in reports: + for line in open(report, 'r'): + if line.startswith('Testcase:'): + oldReports.append(''.join(line.split(':')[:2])) + tmp = [x.strip() for x in open('svn.log', 'r').readlines()] + oldRevision = 'NA' + for line in tmp: + if line.startswith('At revision'): + oldRevision = line.split()[2][:-1] + break + elif line.startswith('Updated to revision'): + oldRevision = line.split()[3][:-1] + break + + + # compile the distro successDist = runAntJob('nice -n 19 ant -lib %s clean dist-large' % (ant_libs), 'build.log', 'distro') if successDist: # if we compiled, do the rest of the stuff @@ -1191,6 +1212,29 @@ if successTest: print ' Generating JUnit section' + + # we'll want to do a diff against the previous runs results, + # but only if it is not a dry run + nTestFixed = 'NA' + nTestFails = 'NA' + if not dryRun: + reports = glob.glob(os.path.join(nightly_repo, 'reports', '*.txt')) + reports.sort() + newReports = [] + for report in reports: + for line in open(report, 'r'): + if line.startswith('Testcase:'): + newReports.append(''.join(line.split(':')[:2])) + + import difflib + diff = difflib.unified_diff(oldReports, newReports) + nTestFixed = 0 + nTestFails = 0 + for i in diff: + if i.startswith('-'): nTestFixed += 1 + if i.startswith('+'): nTestFails += 1 + + # make the directory for reports testDir = os.path.join(nightly_web, 'test') os.mkdir(testDir) @@ -1228,7 +1272,9 @@ os.path.join(nightly_web, 'test.log')) resultTable.addCell("<a href=\"test.log\">test.log</a>") resultTable.appendToCell("<a href=\"junitsummary.html\">Stable</a>") - resultTable.appendToCell("<a href=\"junitsummary-unstable.html\">Unstable</a>") + resultTable.appendToCell("<a href=\"junitsummary-unstable.html\">Unstable</a>") + resultTable.appendToCell("<br>No. old fails fixed since r%s = %s" % (oldRevision,str(nTestFixed))) + resultTable.appendToCell("No. new fails since r%s = %s" % (oldRevision,str(nTestFails))) else: resultTable.addCell("<b>FAILED</b>", klass="tdfail") if os.path.exists( os.path.join(nightly_dir, 'test.log') ): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |