Skip to content

Commit 96c1bd5

Browse files
committed
Remove 385 lines of dead code: DEBUG flags, unused fields, commented-out code
- MCSThread: remove 4 unused imports (Aromaticity, Cycles, MoleculeInitializer) - Isomorphism: remove 2 dead fields + 4 dead getter/setter methods - BaseMapping: remove dead isMoleculeConnected() + 2 unused imports - 10 files: remove DEBUG=false flags and all dead if(DEBUG) blocks - Reactor: remove 25 commented-out System.out.println lines - CDKReactionBuilder: remove 98 lines of dead DEBUG blocks All 135 tests pass. No logic changes. Co-Authored-By: Syed Asad Rahman <asad.rahman@bioinceptionlabs.com>
1 parent da3e122 commit 96c1bd5

14 files changed

Lines changed: 2 additions & 385 deletions

File tree

src/main/java/com/bioinceptionlabs/aamtool/rgroup/ECRgroupFrequency.java

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import java.io.FileReader;
2424
import java.io.IOException;
2525

26-
import java.util.ArrayList;
27-
import static java.util.Arrays.asList;
2826
import java.util.List;
2927
import java.util.Map;
3028
import java.util.Set;
@@ -43,11 +41,6 @@
4341
*/
4442
public class ECRgroupFrequency {
4543

46-
/**
47-
*
48-
*/
49-
protected final static boolean DEBUG = false;
50-
5144
private static final ILoggingTool LOGGER
5245
= LoggingToolFactory.createLoggingTool(ECRgroupFrequency.class);
5346

@@ -71,13 +64,6 @@ public ECRgroupFrequency(String[] args) {
7164
File f = new File(dir);
7265
if (f.isDirectory()) {
7366
File[] files = f.listFiles();
74-
//
75-
if (DEBUG) {
76-
List<File> l = new ArrayList<>();
77-
l.addAll(asList(files));
78-
List<File> subList = l.subList(1, 100);
79-
files = subList.toArray(new File[subList.size()]);
80-
}
8167
for (File ec : files) {
8268
String ecNumber = ec.getName();
8369
if (ec.isDirectory()) {
@@ -132,15 +118,6 @@ public ECRgroupFrequency(String[] args) {
132118
Set<String> r_group_ec = new TreeSet<>();
133119

134120
for (String ec : reactionMap.keySet()) {
135-
if (DEBUG) {
136-
if (reactionMap.get(ec).isRGroup()) {
137-
LOGGER.debug("Processing EC: " + ec
138-
+ ", R-found: " + reactionMap.get(ec).isRGroup()
139-
+ ", common fragment: " + reactionMap.get(ec).getCommonCommonFP().size()
140-
+ ", reaction count: " + reactionMap.get(ec).getReactionCount());
141-
}
142-
}
143-
144121
if (reactionMap.get(ec).isRGroup()) {
145122
r_group_ec.add(ec);
146123
}
@@ -286,21 +263,6 @@ public ECRgroupFrequency(String[] args) {
286263
int more_than_one_union_common = 0;
287264

288265
for (String ec : commonCommonMap.keySet()) {
289-
if (DEBUG) {
290-
if (commonUnionMap.get(ec).isEmpty()) {
291-
LOGGER.debug("EC: " + ec
292-
+ ", Common Signature: " + commonCommonMap.get(ec)
293-
+ ", Difference Signature " + commonDifferenceMap.get(ec)
294-
+ ", Union Common Signature " + commonUnionMap.get(ec));
295-
}
296-
}
297-
298-
//if (commonUnionMap.get(ec).isEmpty()) {
299-
// LOGGER.debug("EC: " + ec
300-
// + ", Common Signature: " + commonCommonMap.get(ec)
301-
// + ", Difference Signature " + commonDifferenceMap.get(ec)
302-
// + ", Union Common Signature " + commonUnionMap.get(ec));
303-
//}
304266
if (commonCommonMap.get(ec).isEmpty() && commonDifferenceMap.get(ec).isEmpty()) {
305267
empty_signature++;
306268
} else if (!commonCommonMap.get(ec).isEmpty() || !commonDifferenceMap.get(ec).isEmpty()) {

src/main/java/com/bioinceptionlabs/reactionblast/mapping/Reactor.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,13 @@ public class Reactor extends AbstractReactor implements Serializable {
108108
boolean partialMapping,
109109
IMappingAlgorithm algorithm)
110110
throws Exception {
111-
//SmilesGenerator smiles = new SmilesGenerator(SmiFlavor.Unique | SmiFlavor.UseAromaticSymbols | SmiFlavor.AtomAtomMap);
112111
if (partialMapping) {
113112
//else CDKToBeam throws an error "Aromatic bond connects non-aromatic atomic atoms"
114113
smiles = new SmilesGenerator(
115-
//SmiFlavor.Unique|
116114
SmiFlavor.AtomAtomMap
117115
| SmiFlavor.Stereo);
118116
} else {
119117
smiles = new SmilesGenerator(
120-
//SmiFlavor.Unique|
121118
SmiFlavor.UseAromaticSymbols
122119
| SmiFlavor.AtomAtomMap
123120
| SmiFlavor.Stereo);
@@ -242,9 +239,6 @@ private void expandReaction() throws CloneNotSupportedException {
242239
reactionWithUniqueSTOICHIOMETRY.setDirection(reactionWithSTOICHIOMETRY.getDirection() == null
243240
? BIDIRECTIONAL
244241
: reactionWithSTOICHIOMETRY.getDirection());
245-
//
246-
// System.out.println("ExpandedEduct Count: " + reactionWithUniqueSTOICHIOMETRY.getReactantCount()
247-
// + ", ExpandedProduct Count: " + reactionWithUniqueSTOICHIOMETRY.getProductCount());
248242

249243
LabelAtoms();
250244
BondCollection();
@@ -253,15 +247,13 @@ private void expandReaction() throws CloneNotSupportedException {
253247
private void LabelAtoms() {
254248
int new_atom_rank_index_reactant = 1;
255249
int new_atom_rank_index_product = 1;
256-
// System.out.println("----------------------------");
257250
for (int i = 0; i < reactionWithUniqueSTOICHIOMETRY.getReactantCount(); i++) {
258251
IAtomContainer container = reactionWithUniqueSTOICHIOMETRY.getReactants().getAtomContainer(i);
259252
for (int k = 0; k < container.getAtomCount(); k++) {
260253
String counter = (substrateAtomCounter).toString();
261254
substrateAtomCounter += 1;
262255
IAtom atom = container.getAtom(k);
263256
atom.setID(counter);
264-
// System.out.println("EAtom: " + k + " " + atom.getSymbol() + " Rank Atom: " + atom.getProperty("OLD_RANK") + " " + " Id: " + atom.getID());
265257
rLabelledAtoms.put(atom.hashCode(), i);
266258
if (atom.getProperty("OLD_RANK") != null) {
267259
inputRankLabelledAtomsReactant.put((int) atom.getProperty("OLD_RANK"), (new_atom_rank_index_reactant++));
@@ -271,15 +263,13 @@ private void LabelAtoms() {
271263
educts.put(i, container);
272264
}
273265

274-
// System.out.println("+++++++++++++++++");
275266
for (int j = 0; j < reactionWithUniqueSTOICHIOMETRY.getProductCount(); j++) {
276267
IAtomContainer container = reactionWithUniqueSTOICHIOMETRY.getProducts().getAtomContainer(j);
277268
for (int k = 0; k < container.getAtomCount(); k++) {
278269
String counter = (productAtomCounter).toString();
279270
productAtomCounter += 1;
280271
IAtom atom = container.getAtom(k);
281272
atom.setID(counter);
282-
// System.out.println("PAtom: " + k + " " + atom.getSymbol() + " Id: " + atom.getID());
283273
pLabelledAtoms.put(atom.hashCode(), j);
284274
if (atom.getProperty("OLD_RANK") != null) {
285275
inputRankLabelledAtomsProduct.put((int) atom.getProperty("OLD_RANK"), (new_atom_rank_index_product++));
@@ -321,7 +311,6 @@ private void checkReactionBalance() throws IOException {
321311
while (rAtomIterator.hasNext()) {
322312
IAtom rAtom = rAtomIterator.next();
323313
if (!rAtom.getSymbol().equals("H")) {
324-
// System.out.println("E: " + rAtom.getSymbol());
325314
if (AtomMap.containsKey(rAtom.getSymbol())) {
326315
int count = AtomMap.get(rAtom.getSymbol()) + 1;
327316
AtomMap.put(rAtom.getSymbol(), count);
@@ -338,7 +327,6 @@ private void checkReactionBalance() throws IOException {
338327
while (pAtomIterator.hasNext()) {
339328
IAtom pAtom = pAtomIterator.next();
340329
if (!pAtom.getSymbol().equals("H")) {
341-
// System.out.println("P: " + atomIndex.getSymbol());
342330
if (AtomMap.containsKey(pAtom.getSymbol())) {
343331
int count = AtomMap.get(pAtom.getSymbol()) - 1;
344332
AtomMap.put(pAtom.getSymbol(), count);
@@ -352,13 +340,11 @@ private void checkReactionBalance() throws IOException {
352340
}
353341

354342
for (Map.Entry<String, Integer> I : AtomMap.entrySet()) {
355-
// System.out.println("A: " + I.getKey() + " V: " + I.getValue());
356343
if (I.getValue() != 0) {
357344
this.balanceFlag = false;
358345
break;
359346
}
360347
}
361-
// System.out.println("Bal: " + balanceFlag);
362348
}
363349

364350
private void calculateAtomAtomMapping() throws IOException, Exception {
@@ -381,8 +367,6 @@ private IReaction getMapping(IReaction coreMappedReaction) throws IOException, C
381367
IReaction mappedReaction = deepClone(reactionWithUniqueSTOICHIOMETRY);
382368
cleanMapping(mappedReaction);
383369

384-
// printReaction(mappedReaction);
385-
386370
/*
387371
* This section set the mappingMap ID for the mapped atoms
388372
*/
@@ -740,7 +724,6 @@ public int getMappingCount() {
740724
}
741725

742726
private IReaction copyReaction(IReaction orignalReaction, boolean removeHydrogen) throws Exception {
743-
// System.out.println("R size: " + orignalReaction.getReactantCount() + " , " + orignalReaction.getProductCount());
744727
IReaction copiedReaction = reactionWithUniqueSTOICHIOMETRY.getBuilder().newInstance(IReaction.class);
745728

746729
for (int i = 0; i < orignalReaction.getReactantCount(); i++) {
@@ -752,13 +735,11 @@ private IReaction copyReaction(IReaction orignalReaction, boolean removeHydrogen
752735
IAtom atom = newMol.getAtom(index);
753736
atom.setProperty("index", index);
754737
}
755-
// System.out.println("Hydrogen Before" + newMol.getAtomCount());
756738

757739
percieveAtomTypesAndConfigureAtoms(newMol);
758740
if (removeHydrogen) {
759741
newMol = removeHydrogensExceptSingleAndPreserveAtomID(newMol);
760742
}
761-
// System.out.println("Hydrogen After" + newMol.getAtomCount());
762743
copiedReaction.addReactant(newMol, st);
763744
}
764745
for (int i = 0; i < orignalReaction.getProductCount(); i++) {
@@ -770,13 +751,11 @@ private IReaction copyReaction(IReaction orignalReaction, boolean removeHydrogen
770751
IAtom atom = newMol.getAtom(index);
771752
atom.setProperty("index", index);
772753
}
773-
// System.out.println("Hydrogen Before " + newMol.getAtomCount());
774754

775755
percieveAtomTypesAndConfigureAtoms(newMol);
776756
if (removeHydrogen) {
777757
newMol = removeHydrogensExceptSingleAndPreserveAtomID(newMol);
778758
}
779-
// System.out.println("Hydrogen After " + newMol.getAtomCount());
780759
copiedReaction.addProduct(newMol, st);
781760
}
782761
copiedReaction.setFlags(orignalReaction.getFlags());
@@ -935,8 +914,6 @@ private IAtom getContainerAtomByID(IAtomContainerSet products, String mappingID)
935914
}
936915

937916
private int setCanonicalMappingLabels(IReaction mappedReaction) throws CDKException {
938-
// ICanonicalMoleculeLabeller cng = new SignatureMoleculeLabeller();
939-
940917
IAtomContainerSet rMolSet = mappedReaction.getReactants();
941918
IAtomContainerSet pMolSet = mappedReaction.getProducts();
942919

@@ -1004,7 +981,6 @@ private int setCanonicalMappingLabels(IReaction mappedReaction) throws CDKExcept
1004981
*/
1005982
for (IAtom qAtom : mol.atoms()) {
1006983
if (mappingMap.containsKey(qAtom) && !qAtom.getSymbol().equalsIgnoreCase("H")) {
1007-
// System.out.println("Atom " + qAtom.getSymbol() + " new Rank: " + counter);
1008984
String id = valueOf(counter);
1009985
qAtom.setID(id);
1010986
mappingMap.get(qAtom).setID(id);
@@ -1021,7 +997,6 @@ private int setCanonicalMappingLabels(IReaction mappedReaction) throws CDKExcept
1021997
*/
1022998
for (IAtom qAtom : mol.atoms()) {
1023999
if (mappingMap.containsKey(qAtom) && qAtom.getSymbol().equalsIgnoreCase("H")) {
1024-
// System.out.println("Atom " + qAtom.getSymbol() + " new Rank: " + counter);
10251000
String id = valueOf(counter);
10261001
qAtom.setID(id);
10271002
mappingMap.get(qAtom).setID(id);

src/main/java/com/bioinceptionlabs/reactionblast/mapping/algorithm/BaseGameTheory.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
import org.openscience.cdk.interfaces.IAtom;
4848
import org.openscience.cdk.interfaces.IAtomContainer;
4949
import org.openscience.cdk.interfaces.IPseudoAtom;
50-
import org.openscience.cdk.smiles.SmiFlavor;
51-
import org.openscience.cdk.smiles.SmilesGenerator;
5250
import org.openscience.cdk.tools.ILoggingTool;
5351
import static org.openscience.cdk.tools.LoggingToolFactory.createLoggingTool;
5452
import org.openscience.smsd.AtomAtomMapping;
@@ -74,7 +72,6 @@
7472
*/
7573
public abstract class BaseGameTheory extends Debugger implements IGameTheory, Serializable {
7674

77-
private final static boolean DEBUG = false;
7875
private final static ILoggingTool LOGGER
7976
= createLoggingTool(BaseGameTheory.class);
8077
private static final long serialVersionUID = 1698688633678282L;
@@ -360,12 +357,6 @@ private MCSSolution getMappings(
360357
}
361358
atomMaps.clear();
362359
if (mappingPossible) {
363-
if (DEBUG) {
364-
LOGGER.debug("Expected Mapping");
365-
SmilesGenerator smilesGenerator = new SmilesGenerator(SmiFlavor.Unique | SmiFlavor.UseAromaticSymbols);
366-
LOGGER.debug(educt.getID() + " ED: " + smilesGenerator.create(educt));
367-
LOGGER.debug(product.getID() + " PD: " + smilesGenerator.create(product));
368-
}
369360
return quickMapping(educt, product, queryPosition, targetPosition);
370361
}
371362
}

src/main/java/com/bioinceptionlabs/reactionblast/mapping/algorithm/CaseHandler.java

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
import org.openscience.cdk.interfaces.IRingSet;
4444
import org.openscience.cdk.silent.SilentChemObjectBuilder;
4545
import org.openscience.cdk.smarts.SmartsPattern;
46-
import org.openscience.cdk.smiles.SmiFlavor;
47-
import org.openscience.cdk.smiles.SmilesGenerator;
4846
import org.openscience.cdk.smiles.SmilesParser;
4947
import org.openscience.cdk.tools.ILoggingTool;
5048
import static org.openscience.cdk.tools.LoggingToolFactory.createLoggingTool;
@@ -78,8 +76,6 @@ protected static void initializeMolecule(IAtomContainer atomContainer) throws CD
7876
private final Map<IRingSet, IAtomContainer> ringContainerCountP;
7977
private final IRingSet sssrEduct;
8078
private final IRingSet sssrProduct;
81-
private final boolean DEBUG = false;
82-
8379
protected final IReaction reaction;
8480

8581
CaseHandler(IReaction reaction) throws Intractable {
@@ -211,12 +207,6 @@ private boolean chipPhophateInSingleReactantProductNotInRing(IAtomContainer educ
211207
if (matchesE && matchesP) {
212208
boolean findAndChipBondPhophate1 = findAndChipBondPhophate(educt);
213209
boolean findAndChipBondPhophate2 = findAndChipBondPhophate(product);
214-
if (DEBUG) {
215-
LOGGER.debug("findAndChipBondPhophate1 Q " + findAndChipBondPhophate1);
216-
LOGGER.debug("findAndChipBondPhophate2 T " + findAndChipBondPhophate2);
217-
LOGGER.debug("SM " + new SmilesGenerator(SmiFlavor.Generic).create(educt));
218-
LOGGER.debug("SM " + new SmilesGenerator(SmiFlavor.Generic).create(product));
219-
}
220210
return findAndChipBondPhophate1 && findAndChipBondPhophate2;
221211
}
222212
}
@@ -276,17 +266,8 @@ private boolean findAndChipBondPhophate(IAtomContainer container) {
276266
if (neighbourBonds.size() == 2) {
277267
neighbourBonds.stream().filter((b) -> (b.getAtom(0).getSymbol().equals("O")
278268
|| b.getAtom(0).getSymbol().equals("P"))).filter((b) -> (b.getAtom(1).getSymbol().equals("O")
279-
|| b.getAtom(1).getSymbol().equals("P"))).map((b) -> {
269+
|| b.getAtom(1).getSymbol().equals("P"))).forEach((b) -> {
280270
container.removeBond(b);
281-
return b;
282-
}).filter((b) -> (DEBUG)).map((b) -> {
283-
LOGGER.debug("bondToBeChipped " + b.getAtom(0).getSymbol());
284-
return b;
285-
}).map((b) -> {
286-
LOGGER.debug("bondToBeChipped " + b.getAtom(1).getSymbol());
287-
return b;
288-
}).forEach((_item) -> {
289-
LOGGER.debug("removeBond o-p ");
290271
});
291272
return true;
292273
}
@@ -311,33 +292,14 @@ private boolean findAndChipBondBetweenRings(IAtomContainer container) {
311292
LOGGER.debug("number_of_rings " + number_of_rings);
312293

313294
List<IBond> bonds = container.getConnectedBondsList(atom);
314-
if (DEBUG) {
315-
LOGGER.debug("number_of_bonds " + bonds.size());
316-
bonds.stream().forEach((bond) -> {
317-
LOGGER.debug("BONDS "
318-
+ " B0 " + bond.getAtom(0).getSymbol()
319-
+ " B1 " + bond.getAtom(1).getSymbol());
320-
});
321-
}
322-
323295
if (bonds.size() == 2 && number_of_rings == 2) {
324296
IBond bondToBeChipped = bonds.iterator().next();
325297
bond_to_be_removed.add(bondToBeChipped);
326298
}
327299
}
328300
}
329-
bond_to_be_removed.stream().map((bond) -> {
301+
bond_to_be_removed.forEach((bond) -> {
330302
container.removeBond(bond);
331-
return bond;
332-
}).filter((bond) -> (DEBUG)).forEach((bond) -> {
333-
try {
334-
LOGGER.debug("CHIPPING BONDS "
335-
+ " B0 " + bond.getAtom(0).getSymbol()
336-
+ " B1 " + bond.getAtom(1).getSymbol());
337-
LOGGER.debug("CHIPPED SM " + new SmilesGenerator(SmiFlavor.Generic).create(container));
338-
} catch (CDKException ex) {
339-
LOGGER.error(SEVERE, "Clipping Bonds: ", ex.getMessage());
340-
}
341303
});
342304
return !bond_to_be_removed.isEmpty();
343305
}
@@ -359,15 +321,6 @@ private boolean case1(IAtomContainer s, IAtomContainer t) throws InvalidSmilesEx
359321
String moiety = "NC(=O)C1=CN(C=N1)C1OC(COP(O)(O)=O)C(O)C1O";
360322
IAtomContainer query = smilesParser.parseSmiles(moiety);
361323

362-
if (DEBUG) {
363-
LOGGER.debug("case2 QSM " + new SmilesGenerator(SmiFlavor.Generic).create(s));
364-
LOGGER.debug("case2 TSM " + new SmilesGenerator(SmiFlavor.Generic).create(t));
365-
// boolean match1 = isMatch(query, s, true);
366-
// boolean match2 = isMatch(query, t, true);
367-
// System.out.println("Sub 1 " + match1);
368-
// System.out.println("Sub 2 " + match2);
369-
}
370-
371324
if (isMatch(query, s, false) && isMatch(query, t, false)) {
372325

373326
IAtomContainer ac1 = s;

0 commit comments

Comments
 (0)