Skip to content
Permalink
Browse files

As final

Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information...
gilleain authored and egonw committed Jul 21, 2011
1 parent c3d28b6 commit f0a327da63ef4e1022f6d9be0a67a92efd746d72
@@ -1228,7 +1228,51 @@ private IAtomType perceiveHalogens(IAtomContainer atomContainer, IAtom atom)
}
return null;
}

private IAtomType perceiveArsenic(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (hasOneSingleElectron(atomContainer, atom)) {
// no idea how to deal with this yet
return null;
} else if ((atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == +1
&& atomContainer.getConnectedBondsCount(atom) <= 4)) {
IAtomType type = getAtomType("As.plus");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
} else if ((atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 0)) {
int neighbors = atomContainer.getConnectedAtomsCount(atom);
if (neighbors == 4) {
IAtomType type = getAtomType("As.5");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
}
if (neighbors == 2) {
IAtomType type = getAtomType("As.2");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
}
IAtomType type = getAtomType("As");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
} else if ((atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == +3)) {
IAtomType type = getAtomType("As.3plus");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
} else if ((atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == -1)) {
IAtomType type = getAtomType("As.minus");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
}
return null;
}
private IAtomType perceiveCommonSalts(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if ("Na".equals(atom.getSymbol())) {
if (hasOneSingleElectron(atomContainer, atom)) {
@@ -1398,22 +1442,7 @@ private IAtomType perceiveOrganometallicCenters(IAtomContainer atomContainer, IA
IAtomType type = getAtomType("Sn.sp3");
if (isAcceptable(atom, atomContainer, type)) return type;
}
} else if ("As".equals(atom.getSymbol())) {
if (hasOneSingleElectron(atomContainer, atom)) {
// no idea how to deal with this yet
return null;
} else if ((atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == +1 &&
atomContainer.getConnectedBondsCount(atom) <= 4)) {
IAtomType type = getAtomType("As.plus");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if ((atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == 0 &&
atomContainer.getConnectedBondsCount(atom) <= 3)) {
IAtomType type = getAtomType("As");
if (isAcceptable(atom, atomContainer, type)) return type;
}
} else if ("Ti".equals(atom.getSymbol())) {
} else if ("Ti".equals(atom.getSymbol())) {
if (atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == -3 &&
atomContainer.getConnectedBondsCount(atom) == 6) {
@@ -1329,24 +1329,55 @@
<at:piBondCount>0</at:piBondCount>
<at:hybridization rdf:resource="&at;sp3"/>
</at:AtomType>

<at:AtomType rdf:ID="As.plus">
<at:AtomType rdf:ID="As.plus">
<at:formalCharge>1</at:formalCharge>
<at:hasElement rdf:resource="&elem;As"/>
<at:formalNeighbourCount>4</at:formalNeighbourCount>
<at:lonePairCount>0</at:lonePairCount>
<at:piBondCount>0</at:piBondCount>
<at:hybridization rdf:resource="&at;sp3"/>
</at:AtomType>
</at:AtomType>

<at:AtomType rdf:ID="As">
<at:AtomType rdf:ID="As">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;As"/>
<at:formalNeighbourCount>3</at:formalNeighbourCount>
<at:lonePairCount>1</at:lonePairCount>
<at:piBondCount>0</at:piBondCount>
<at:hybridization rdf:resource="&at;sp3"/>
</at:AtomType>
</at:AtomType>

<at:AtomType rdf:ID="As.5">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;As"/>
<at:formalNeighbourCount>4</at:formalNeighbourCount>
<at:lonePairCount>0</at:lonePairCount>
<at:piBondCount>1</at:piBondCount>
<at:hybridization rdf:resource="&at;sp3"/>
</at:AtomType>

<at:AtomType rdf:ID="As.2">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;As"/>
<at:formalNeighbourCount>2</at:formalNeighbourCount>
<at:lonePairCount>1</at:lonePairCount>
<at:piBondCount>1</at:piBondCount>
<at:hybridization rdf:resource="&at;sp2"/>
</at:AtomType>

<at:AtomType rdf:ID="As.3plus">
<at:formalCharge>3</at:formalCharge>
<at:hasElement rdf:resource="&elem;As"/>
<at:formalNeighbourCount>0</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="As.minus">
<at:formalCharge>-1</at:formalCharge>
<at:hasElement rdf:resource="&elem;As"/>
<at:formalNeighbourCount>6</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Hg.minus">
<at:formalCharge>-1</at:formalCharge>
@@ -3615,7 +3615,7 @@ public void testMethylphosphinicAcid() throws Exception {
};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

@Test
public void test_Mn_3plus() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
@@ -3759,6 +3759,120 @@ public void test_Si_2() throws Exception {
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}


@Test
public void test_As_minus() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"As");
a1.setFormalCharge(-1);
mol.addAtom(a1);
IAtom a2 = builder.newInstance(IAtom.class,"C");
a2.setFormalCharge(0);
mol.addAtom(a2);
IAtom a3 = builder.newInstance(IAtom.class,"C");
a3.setFormalCharge(0);
mol.addAtom(a3);
IAtom a4 = builder.newInstance(IAtom.class,"C");
a4.setFormalCharge(0);
mol.addAtom(a4);
IAtom a5 = builder.newInstance(IAtom.class,"C");
a5.setFormalCharge(0);
mol.addAtom(a5);
IAtom a6 = builder.newInstance(IAtom.class,"C");
a6.setFormalCharge(0);
mol.addAtom(a6);
IAtom a7 = builder.newInstance(IAtom.class,"C");
a7.setFormalCharge(0);
mol.addAtom(a7);
IBond b1 = builder.newInstance(IBond.class,a1, a2, IBond.Order.SINGLE);
mol.addBond(b1);
IBond b2 = builder.newInstance(IBond.class,a1, a3, IBond.Order.SINGLE);
mol.addBond(b2);
IBond b3 = builder.newInstance(IBond.class,a1, a4, IBond.Order.SINGLE);
mol.addBond(b3);
IBond b4 = builder.newInstance(IBond.class,a1, a5, IBond.Order.SINGLE);
mol.addBond(b4);
IBond b5 = builder.newInstance(IBond.class,a1, a6, IBond.Order.SINGLE);
mol.addBond(b5);
IBond b6 = builder.newInstance(IBond.class,a1, a7, IBond.Order.SINGLE);
mol.addBond(b6);


String[] expectedTypes = {"As.minus", "C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

@Test
public void test_As_3plus() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"As");
a1.setFormalCharge(3);
mol.addAtom(a1);


String[] expectedTypes = {"As.3plus"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

@Test
public void test_As_2() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"C");
a1.setFormalCharge(0);
mol.addAtom(a1);
IAtom a2 = builder.newInstance(IAtom.class,"As");
a2.setFormalCharge(0);
mol.addAtom(a2);
IAtom a3 = builder.newInstance(IAtom.class,"C");
a3.setFormalCharge(0);
mol.addAtom(a3);
IBond b1 = builder.newInstance(IBond.class,a1, a2, IBond.Order.SINGLE);
mol.addBond(b1);
IBond b2 = builder.newInstance(IBond.class,a2, a3, IBond.Order.DOUBLE);
mol.addBond(b2);


String[] expectedTypes = {"C.sp3", "As.2", "C.sp2"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

@Test
public void test_As_5() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"As");
a1.setFormalCharge(0);
mol.addAtom(a1);
IAtom a2 = builder.newInstance(IAtom.class,"C");
a2.setFormalCharge(0);
mol.addAtom(a2);
IAtom a3 = builder.newInstance(IAtom.class,"C");
a3.setFormalCharge(0);
mol.addAtom(a3);
IAtom a4 = builder.newInstance(IAtom.class,"C");
a4.setFormalCharge(0);
mol.addAtom(a4);
IAtom a5 = builder.newInstance(IAtom.class,"C");
a5.setFormalCharge(0);
mol.addAtom(a5);
IBond b1 = builder.newInstance(IBond.class,a1, a2, IBond.Order.SINGLE);
mol.addBond(b1);
IBond b2 = builder.newInstance(IBond.class,a1, a3, IBond.Order.SINGLE);
mol.addBond(b2);
IBond b3 = builder.newInstance(IBond.class,a1, a4, IBond.Order.SINGLE);
mol.addBond(b3);
IBond b4 = builder.newInstance(IBond.class,a1, a5, IBond.Order.DOUBLE);
mol.addBond(b4);


String[] expectedTypes = {"As.5", "C.sp3", "C.sp3", "C.sp3", "C.sp2"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}


/*
* This method *must* be the last method in the class.
*/

0 comments on commit f0a327d

Please sign in to comment.
You can’t perform that action at this time.