Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Helper methods now return results, rather than change parameter conte…
…nt, and uses interfaces as variable types rather than implementations (patch by Kevin Lawson).

Change-Id: Iba28472b2e1837e44667ffb14aa44f523c3831fc

Signed-off-by: Rajarshi Guha <rajarshi.guha@gmail.com>
  • Loading branch information
egonw authored and rajarshi committed Mar 22, 2012
1 parent e9c3f4b commit d4c4af2
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/main/org/openscience/cdk/smiles/DeduceBondSystemTool.java
Expand Up @@ -147,16 +147,14 @@ public IMolecule fixAromaticBondOrders(IMolecule molecule) throws CDKException {
this.FixPyridineNOxides(molecule,ringSet);

//We need to establish which rings share bonds and set up sets of such interdependant rings
List<Integer[]> rBondsArray;
rBondsArray= new ArrayList<Integer[]>();
List<List<Integer>> ringGroups;
ringGroups = new ArrayList<List<Integer>>();
List<Integer[]> rBondsArray = null;
List<List<Integer>> ringGroups = null;

//Start by getting a list (same dimensions and ordering as ringset) of all the ring bond numbers in the reduced ring set
getRingSystem(molecule, ringSet, rBondsArray);
rBondsArray = getRingSystem(molecule, ringSet);

//Now find out which share a bond and assign them accordingly to groups
assignRingGroups(rBondsArray, ringGroups);
ringGroups = assignRingGroups(rBondsArray);

//Set up the array of MasterLists to pass to Loop function - one for each dependant group of rings
List<List> MasterLists;
Expand Down Expand Up @@ -848,14 +846,17 @@ private boolean[] findRingsToCheck(IRingSet rs) {
* @param mol The IMolecule for which to store the IRingSet.
* @param ringSet The IRingSet to store
*/
private void getRingSystem(IMolecule mol, IRingSet ringSet, List<Integer[]> bondsArray) {
private List<Integer[]> getRingSystem(IMolecule mol, IRingSet ringSet) {
List<Integer[]> bondsArray;
bondsArray= new ArrayList<Integer[]>();
for (int r = 0; r < ringSet.getAtomContainerCount(); ++r) {
IRing ring = (IRing)ringSet.getAtomContainer(r);
Integer[] bondNumbers = new Integer[ring.getBondCount()];
for (int i = 0; i < ring.getBondCount(); ++i)
bondNumbers[i] = mol.getBondNumber(ring.getBond(i));
bondsArray.add(bondNumbers);
}
return bondsArray;
}
/**
* Stores an IRingSet corresponding to a molecule using the bond numbers.
Expand All @@ -878,7 +879,9 @@ private void storeRingSystem(IMolecule mol, IRingSet ringSet) {
* @param rBondsArray
* @param ringGroups
*/
private void assignRingGroups(List<Integer[]> rBondsArray, List<List<Integer>> ringGroups){
private List<List<Integer>> assignRingGroups(List<Integer[]> rBondsArray){
List<List<Integer>> ringGroups;
ringGroups = new ArrayList<List<Integer>>();
for(int i = 0; i < rBondsArray.size()-1; i++){ //for each ring except the last in rBondsArray
for(int j = 0; j < rBondsArray.get(i).length; j++){ //for each bond in each ring

Expand Down Expand Up @@ -914,6 +917,7 @@ private void assignRingGroups(List<Integer[]> rBondsArray, List<List<Integer>> r
ringGroups.get(ringGroups.size()-1).add(i);
}
}
return ringGroups;
}
/**
*
Expand Down Expand Up @@ -971,10 +975,10 @@ private IMolecule combineRetMols(List<IMolecule> retMols){

//Only work on the relevant ring bonds
IRingSet ringset = removeExtraRings(combi);
ArrayList<Integer[]> rBondsArray = new ArrayList<Integer[]>();
List<Integer[]> rBondsArray = null;

//Get hold of the bond numbers
getRingSystem(combi, ringset, rBondsArray);
rBondsArray = getRingSystem(combi, ringset);

//Cycle through each molecule
for(int i = 1; i < retMols.size(); i++){
Expand Down

0 comments on commit d4c4af2

Please sign in to comment.