Skip to content

Commit

Permalink
Merge pull request #322 from cdk/findbugs
Browse files Browse the repository at this point in the history
Yeah, amazing how easily one does not notice these small silly mistakes....
  • Loading branch information
egonw committed May 18, 2017
2 parents 9779b93 + d56977d commit 1ecebf6
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
if (atoml != null && atoml.getFlag(CDKConstants.REACTIVE_CENTER)
&& !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomhs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomhs.hasNext()) {
Expand Down Expand Up @@ -213,7 +213,7 @@ private void setActiveCenters(IAtomContainer reactant) throws CDKException {
IAtom atoml = atomls.next();
if (atoml != null && !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomhs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomhs.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
if (atoml != null && atoml.getFlag(CDKConstants.REACTIVE_CENTER)
&& !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomhs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomhs.hasNext()) {
Expand Down Expand Up @@ -213,7 +213,7 @@ private void setActiveCenters(IAtomContainer reactant) throws CDKException {
IAtom atoml = atomls.next();
if (atoml != null && !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomhs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomhs.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
if (atoml != null && atoml.getFlag(CDKConstants.REACTIVE_CENTER)
&& !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomhs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomhs.hasNext()) {
Expand Down Expand Up @@ -213,7 +213,7 @@ private void setActiveCenters(IAtomContainer reactant) throws CDKException {
IAtom atoml = atomls.next();
if (atoml != null && !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomhs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomhs.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
if (atoml != null && atoml.getFlag(CDKConstants.REACTIVE_CENTER)
&& !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomhs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomhs.hasNext()) {
Expand Down Expand Up @@ -214,7 +214,7 @@ private void setActiveCenters(IAtomContainer reactant) throws CDKException {
IAtom atoml = atomls.next();
if (atoml != null && !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomhs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomhs.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
if (atoml != null && atoml.getFlag(CDKConstants.REACTIVE_CENTER)
&& !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomRs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomRs.hasNext()) {
Expand Down Expand Up @@ -222,7 +222,7 @@ private void setActiveCenters(IAtomContainer reactant) throws CDKException {
IAtom atoml = atomls.next();
if (atoml != null && !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomRs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomRs.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
if (atoml != null && atoml.getFlag(CDKConstants.REACTIVE_CENTER)
&& !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomRs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomRs.hasNext()) {
Expand Down Expand Up @@ -222,7 +222,7 @@ private void setActiveCenters(IAtomContainer reactant) throws CDKException {
IAtom atoml = atomls.next();
if (atoml != null && !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomRs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomRs.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
if (atoml != null && atoml.getFlag(CDKConstants.REACTIVE_CENTER)
&& !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomRs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomRs.hasNext()) {
Expand Down Expand Up @@ -222,7 +222,7 @@ private void setActiveCenters(IAtomContainer reactant) throws CDKException {
IAtom atoml = atomls.next();
if (atoml != null && !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomRs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomRs.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
if (atoml != null && atoml.getFlag(CDKConstants.REACTIVE_CENTER)
&& !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomRs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomRs.hasNext()) {
Expand Down Expand Up @@ -222,7 +222,7 @@ private void setActiveCenters(IAtomContainer reactant) throws CDKException {
IAtom atoml = atomls.next();
if (atoml != null && !atoml.getFlag(CDKConstants.ISINRING)
&& (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
&& !atoml.equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {
&& !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

Iterator<IAtom> atomRs = reactant.getConnectedAtomsList(atoml).iterator();
while (atomRs.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ else if (familyOxygen(atom))
public static double predictIP(IAtomContainer container, IBond bond) throws CDKException {
double value = 0;

if (bond.equals(IBond.Order.SINGLE)) return value;
if (bond.getOrder().equals(IBond.Order.SINGLE)) return value;

//if some of the atoms belongs to some of the heteroatom family than
// it can not ionized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,14 @@ private void writeCrystal(ICrystal crystal) {
write(" ");
}
write(" ");
String elemID = Integer.valueOf(asortedElements.indexOf(symbol) + 1).toString();
String elemID = null;
for (int elemidx = 0; elemidx < asortedElements.size(); elemidx++) {
IElement elem = asortedElements.get(elemidx);
if (elem.getSymbol().equals(symbol)) {
elemID = Integer.toString(elemidx + 1);
break;
}
}
write(elemID);
write(" ".substring(elemID.length()));
write(format.reset("%7.5f").format(fracCoord.x) + " ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@

public class HybridizationNumberAtom extends SMARTSAtom {

Hybridization hybridization;

/**
* Creates a new instance
*
Expand All @@ -48,28 +46,28 @@ public HybridizationNumberAtom(int hybridizationNumber, IChemObjectBuilder build
super(builder);
switch (hybridizationNumber) {
case 1:
hybridization = IAtomType.Hybridization.SP1;
setHybridization(IAtomType.Hybridization.SP1);
break;
case 2:
hybridization = IAtomType.Hybridization.SP2;
setHybridization(IAtomType.Hybridization.SP2);
break;
case 3:
hybridization = IAtomType.Hybridization.SP3;
setHybridization(IAtomType.Hybridization.SP3);
break;
case 4:
hybridization = IAtomType.Hybridization.SP3D1;
setHybridization(IAtomType.Hybridization.SP3D1);
break;
case 5:
hybridization = IAtomType.Hybridization.SP3D2;
setHybridization(IAtomType.Hybridization.SP3D2);
break;
case 6:
hybridization = IAtomType.Hybridization.SP3D3;
setHybridization(IAtomType.Hybridization.SP3D3);
break;
case 7:
hybridization = IAtomType.Hybridization.SP3D4;
setHybridization(IAtomType.Hybridization.SP3D4);
break;
case 8:
hybridization = IAtomType.Hybridization.SP3D5;
setHybridization(IAtomType.Hybridization.SP3D5);
break;
}
}
Expand All @@ -82,7 +80,7 @@ public HybridizationNumberAtom(int hybridizationNumber, IChemObjectBuilder build
*/
@Override
public boolean matches(IAtom atom) {
return hybridization == atom.getHybridization();
return getHybridization() == atom.getHybridization();
}

/*
Expand All @@ -91,7 +89,7 @@ public boolean matches(IAtom atom) {
*/
@Override
public String toString() {
return ("HybridizationNumberAtom(" + hybridization.toString() + ")");
return ("HybridizationNumberAtom(" + getHybridization() + ")");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ public IAtomContainer proposeStructure() {
logger.debug("RandomGenerator->proposeStructure() Start");
do {
try {
trial = (IAtomContainer) molecule.clone();
trial = molecule.clone();
} catch (CloneNotSupportedException e) {
logger.error("Could not clone IAtomContainer!" + e.getMessage());
trial = null;
throw new IllegalStateException("Could not clone IAtomContainer!" + e.getMessage());
}
mutate(trial);
if (logger.isDebugEnabled()) {
Expand Down

0 comments on commit 1ecebf6

Please sign in to comment.