Skip to content

Commit

Permalink
Replace deprecated getConnectedAtomsCount usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed May 7, 2017
1 parent fc36744 commit abf7bd7
Show file tree
Hide file tree
Showing 21 changed files with 78 additions and 78 deletions.

Large diffs are not rendered by default.

Expand Up @@ -97,7 +97,7 @@ public static double calculate(IAtomContainer molecule) throws CDKException {
if (type == null) throw new CDKException("Unknown atom type for atom: " + atom.getSymbol());
if (type.getFormalNeighbourCount() == null)
throw new CDKException("Formal neighbor count not given for : " + type.getAtomTypeName());
int hCount = type.getFormalNeighbourCount() - molecule.getConnectedAtomsCount(atom);
int hCount = type.getFormalNeighbourCount() - molecule.getConnectedBondsCount(atom);
sum += (hCount * bondiiVolumes.get("H"));
totalHCount += hCount;
}
Expand Down
Expand Up @@ -738,13 +738,13 @@ public void testSulfurCompound_ImplicitHydrogens() throws Exception {
Assert.assertEquals("S", sulfur.getSymbol());
Assert.assertNotNull(sulfur.getImplicitHydrogenCount());
Assert.assertEquals(0, sulfur.getImplicitHydrogenCount().intValue());
Assert.assertEquals(3, atomContainer_0.getConnectedAtomsCount(sulfur));
Assert.assertEquals(3, atomContainer_0.getConnectedBondsCount(sulfur));

Assert.assertEquals(10, atomContainer_0.getAtomCount());

Assert.assertNotNull(sulfur.getImplicitHydrogenCount());
Assert.assertEquals(0, sulfur.getImplicitHydrogenCount().intValue());
Assert.assertEquals(3, atomContainer_0.getConnectedAtomsCount(sulfur));
Assert.assertEquals(3, atomContainer_0.getConnectedBondsCount(sulfur));
}

/**
Expand Down
Expand Up @@ -129,6 +129,6 @@ public void addImplicitHydrogens(IAtomContainer container, IAtom atom) throws CD
+ atom.getAtomTypeName());

// very simply counting: each missing explicit neighbor is a missing hydrogen
atom.setImplicitHydrogenCount(type.getFormalNeighbourCount() - container.getConnectedAtomsCount(atom));
atom.setImplicitHydrogenCount(type.getFormalNeighbourCount() - container.getConnectedBondsCount(atom));
}
}
Expand Up @@ -357,7 +357,7 @@ public boolean isSaturated(IAtom atom, IAtomContainer container) throws CDKExcep

public int calculateNumberOfImplicitHydrogens(IAtom atom, IAtomContainer container) throws CDKException {
return this.calculateNumberOfImplicitHydrogens(atom, container.getBondOrderSum(atom),
container.getMaximumBondOrder(atom), container.getConnectedAtomsCount(atom));
container.getMaximumBondOrder(atom), container.getConnectedBondsCount(atom));
}

protected AtomTypeFactory getAtomTypeFactory(IChemObjectBuilder builder) throws CDKException {
Expand Down
Expand Up @@ -110,7 +110,7 @@ public static double evalSimpleIndex(IAtomContainer atomContainer, List<List<Int
double prod = 1.0;
for (Integer atomSerial : fragList) {
IAtom atom = atomContainer.getAtom(atomSerial);
int nconnected = atomContainer.getConnectedAtomsCount(atom);
int nconnected = atomContainer.getConnectedBondsCount(atom);
prod = prod * nconnected;
}
if (prod != 0) sum += 1.0 / Math.sqrt(prod);
Expand Down
Expand Up @@ -156,7 +156,7 @@ private int getUnsaturation(IAtomContainer container, IAtom atom) {
}

private int countNeighbors(IAtomContainer container, IAtom atom) {
return container.getConnectedAtomsCount(atom);
return container.getConnectedBondsCount(atom);
}

private int countImplicitHydrogens(IAtom atom) {
Expand Down
Expand Up @@ -130,7 +130,7 @@ public DefaultMCSPlusAtomMatcher(IQueryAtom smartQueryAtom, IQueryAtomContainer
public DefaultMCSPlusAtomMatcher(IAtomContainer queryContainer, IAtom template, int blockedPositions,
boolean shouldMatchBonds) {
this(queryContainer, template, shouldMatchBonds);
this.maximumNeighbors = countImplicitHydrogens(template) + queryContainer.getConnectedAtomsCount(template)
this.maximumNeighbors = countImplicitHydrogens(template) + queryContainer.getConnectedBondsCount(template)
- blockedPositions;
}

Expand Down Expand Up @@ -161,7 +161,7 @@ private boolean matchMaximumNeighbors(IAtomContainer targetContainer, IAtom targ
return true;
}

int maximumTargetNeighbors = targetContainer.getConnectedAtomsCount(targetAtom);
int maximumTargetNeighbors = targetContainer.getConnectedBondsCount(targetAtom);
return maximumTargetNeighbors >= maximumNeighbors;
}

Expand Down
Expand Up @@ -174,6 +174,6 @@ private int countSaturation(IAtomContainer container, IAtom atom) {
}

private int countNeighbors(IAtomContainer container, IAtom atom) {
return container.getConnectedAtomsCount(atom);
return container.getConnectedBondsCount(atom);
}
}
Expand Up @@ -131,7 +131,7 @@ public DefaultVFAtomMatcher(IQueryAtom smartQueryAtom, IQueryAtomContainer conta
public DefaultVFAtomMatcher(IAtomContainer queryContainer, IAtom template, int blockedPositions,
boolean shouldMatchBonds) {
this(queryContainer, template, shouldMatchBonds);
this.maximumNeighbors = countImplicitHydrogens(template) + queryContainer.getConnectedAtomsCount(template)
this.maximumNeighbors = countImplicitHydrogens(template) + queryContainer.getConnectedBondsCount(template)
- blockedPositions;
}

Expand Down
Expand Up @@ -167,7 +167,7 @@ private int getUnsaturation(IAtomContainer container, IAtom atom) {
}

private int countNeighbors(IAtomContainer container, IAtom atom) {
return container.getConnectedAtomsCount(atom);
return container.getConnectedBondsCount(atom);
}

private int countImplicitHydrogens(IAtom atom) {
Expand Down
Expand Up @@ -96,7 +96,7 @@ public TargetProperties(IAtomContainer container) {
connectedTargetAtomListMap = new HashMap<IAtom, List<IAtom>>();
map = new IBond[container.getAtomCount()][container.getAtomCount()];
for (IAtom atom : container.atoms()) {
int count = container.getConnectedAtomsCount(atom);
int count = container.getConnectedBondsCount(atom);
connectedTargetAtomCountMap.put(atom, count);
List<IAtom> list = container.getConnectedAtomsList(atom);
if (list != null) {
Expand Down
Expand Up @@ -85,7 +85,7 @@ private static boolean fixNitroGroups(IAtomContainer m) {
for (int j = 0; j <= 2; j++) {
IAtom caj = (IAtom) ca.get(j);
if (caj.getSymbol().equals("O")) {
if (m.getConnectedAtomsCount(caj) == 1) {// account for possibility of ONO2
if (m.getConnectedBondsCount(caj) == 1) {// account for possibility of ONO2
cao[count] = caj;
count++;
}
Expand Down Expand Up @@ -146,7 +146,7 @@ public static boolean fixNitroGroups2(IAtomContainer m) {
for (int j = 0; j <= 2; j++) {
IAtom caj = (IAtom) ca.get(j);
if (caj.getSymbol().equals("O")) {
if (m.getConnectedAtomsCount(caj) == 1) {// account for possibility of ONO2
if (m.getConnectedBondsCount(caj) == 1) {// account for possibility of ONO2
cao[count] = caj;
count++;
}
Expand Down
Expand Up @@ -832,7 +832,7 @@ public void testSFBug956926() throws Exception {

// I can also check whether all carbons have exact two neighbors
for (int i = 0; i < mol.getAtomCount(); i++) {
Assert.assertEquals(2, mol.getConnectedAtomsCount(mol.getAtom(i)));
Assert.assertEquals(2, mol.getConnectedBondsCount(mol.getAtom(i)));
}
// and the number of implicit hydrogens
int hCount = 0;
Expand Down Expand Up @@ -932,7 +932,7 @@ public void testSFBug956921() throws Exception {
while (atoms.hasNext()) {
IAtom atomi = atoms.next();
Assert.assertEquals(1, atomi.getImplicitHydrogenCount().intValue());
Assert.assertEquals(2, mol.getConnectedAtomsCount(atomi));
Assert.assertEquals(2, mol.getConnectedBondsCount(atomi));
}
// and the first atom should have a negative charge
Assert.assertEquals(-1, mol.getAtom(0).getFormalCharge().intValue());
Expand Down Expand Up @@ -2181,9 +2181,9 @@ public void testRingClosure() throws Exception {
Assert.assertEquals("C", mol.getAtom(0).getSymbol());
Assert.assertEquals("O", mol.getAtom(1).getSymbol());
Assert.assertEquals("C", mol.getAtom(2).getSymbol());
Assert.assertEquals(4, mol.getConnectedAtomsCount(mol.getAtom(0)));
Assert.assertEquals(2, mol.getConnectedAtomsCount(mol.getAtom(1)));
Assert.assertEquals(2, mol.getConnectedAtomsCount(mol.getAtom(2)));
Assert.assertEquals(4, mol.getConnectedBondsCount(mol.getAtom(0)));
Assert.assertEquals(2, mol.getConnectedBondsCount(mol.getAtom(1)));
Assert.assertEquals(2, mol.getConnectedBondsCount(mol.getAtom(2)));
}

@Test
Expand Down Expand Up @@ -2486,10 +2486,10 @@ public void testDiBorane() throws Exception {

IAtomContainer mol = loadExact(smiles);
Assert.assertEquals(8, mol.getAtomCount());
Assert.assertEquals(4, mol.getConnectedAtomsCount(mol.getAtom(1)));
Assert.assertEquals(2, mol.getConnectedAtomsCount(mol.getAtom(3)));
Assert.assertEquals(4, mol.getConnectedAtomsCount(mol.getAtom(4)));
Assert.assertEquals(2, mol.getConnectedAtomsCount(mol.getAtom(5)));
Assert.assertEquals(4, mol.getConnectedBondsCount(mol.getAtom(1)));
Assert.assertEquals(2, mol.getConnectedBondsCount(mol.getAtom(3)));
Assert.assertEquals(4, mol.getConnectedBondsCount(mol.getAtom(4)));
Assert.assertEquals(2, mol.getConnectedBondsCount(mol.getAtom(5)));
}

/**
Expand Down
Expand Up @@ -175,7 +175,7 @@ private List<IBond> getSplitableBonds(IAtomContainer atomContainer) throws CDKEx

// lets see if it is a terminal bond
for (IAtom atom : bond.atoms()) {
if (atomContainer.getConnectedAtomsCount(atom) == 1) {
if (atomContainer.getConnectedBondsCount(atom) == 1) {
isTerminal = true;
break;
}
Expand Down
Expand Up @@ -115,7 +115,7 @@ protected static List<IBond> traverse(IAtomContainer atomContainer, IAtom atom,
if (bondList.contains(aBond)) continue;
bondList.add(aBond);
IAtom nextAtom = aBond.getOther(atom);
if (atomContainer.getConnectedAtomsCount(nextAtom) == 1) continue;
if (atomContainer.getConnectedBondsCount(nextAtom) == 1) continue;
traverse(atomContainer, nextAtom, bondList);
}
return bondList;
Expand Down
Expand Up @@ -52,4 +52,4 @@ public String toString() {
return value.toString();
}

}
}
Expand Up @@ -29,4 +29,4 @@
* @cdk.module group
*
*/
public interface Invariant extends Comparable<Invariant> { }
public interface Invariant extends Comparable<Invariant> { }
Expand Up @@ -107,7 +107,7 @@ public int encode(IAtom atom, IAtomContainer container) {
*/
@Override
public int encode(IAtom atom, IAtomContainer container) {
return container.getConnectedAtomsCount(atom);
return container.getConnectedBondsCount(atom);
}
},
/**
Expand Down
Expand Up @@ -126,9 +126,9 @@ public void testNConnectedAtoms() {
IAtomContainer container = mock(IAtomContainer.class);
AtomEncoder encoder = BasicAtomEncoder.N_CONNECTED_ATOMS;

when(container.getConnectedAtomsCount(atom)).thenReturn(2);
when(container.getConnectedBondsCount(atom)).thenReturn(2);
assertThat(encoder.encode(atom, container), is(2));
verify(container, times(1)).getConnectedAtomsCount(atom);
verify(container, times(1)).getConnectedBondsCount(atom);
verifyNoMoreInteractions(atom, container);
}

Expand Down
Expand Up @@ -181,7 +181,7 @@ public void distributePartners(IAtom atom, IAtomContainer placedNeighbours, Poin

int numTerminal = 0;
for (IAtom unplaced : unplacedNeighbours.atoms())
if (molecule.getConnectedAtomsCount(unplaced) == 1)
if (molecule.getConnectedBondsCount(unplaced) == 1)
numTerminal++;

if (numTerminal == unplacedNeighbours.getAtomCount()) {
Expand Down

0 comments on commit abf7bd7

Please sign in to comment.