Permalink
Browse files

Fixed pickLargestFragment. Solves #2040.

  • Loading branch information...
1 parent c6c6f68 commit f0f476e51a3751714513e246ec51bd56995b9b79 @olas committed Jul 5, 2010
Showing with 12 additions and 3 deletions.
  1. +12 −3 plugins/net.bioclipse.qsar/src/net/bioclipse/qsar/business/QsarManager.java
@@ -1469,16 +1469,25 @@ public void addResourcesAndResponsesToQsarModel(
//If we should pick largest fragment, do so now
if (pickLargestFragment){
- logger.debug("Selecting largest fragment if not connected.");
List<IAtomContainer> containers = cdk.partition(mol);
if (containers.size()>1){
+ logger.debug("Molecule contains " + mol.getAtomContainer().getAtomCount() + " and is not connected. Picking largest fragment.");
IAtomContainer largest=null;
for (IAtomContainer ac : containers){
if (largest==null)
largest=ac;
- else if (ac.getAtomCount() > largest.getAtomCount())
- largest=ac;
+ else if (ac.getAtomCount() > largest.getAtomCount()){
+ //remove atoms and bonds from AC from largest
+ mol.getAtomContainer().remove(largest);
+ logger.debug(" Removed " + largest.getAtomCount() + " atoms and " + largest.getBondCount() + " bonds from AC");
+ }
+ else{
+ //remove atoms and bonds from AC from ac
+ mol.getAtomContainer().remove(ac);
+ logger.debug(" Removed " + ac.getAtomCount() + " atoms and " + ac.getBondCount() + " bonds from AC");
+ }
}
+ logger.debug("Molecule has " + mol.getAtomContainer().getAtomCount() + " atoms after fragment removal.");
}
}

0 comments on commit f0f476e

Please sign in to comment.