Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Some code clean up: generics and one variable now starting with a low…

…er case char

Signed-off-by: Rajarshi  Guha <rajarshi.guha@gmail.com>
  • Loading branch information...
commit dff478cb4ad05f53395016af58b9d3342a85a24a 1 parent 89b0f1e
Egon Willighagen egonw authored rajarshi committed
32 src/main/org/openscience/cdk/modeling/builder3d/TemplateExtractor.java
View
@@ -34,12 +34,13 @@
import java.util.Map;
import org.openscience.cdk.CDKConstants;
-import org.openscience.cdk.fingerprint.Fingerprinter;
+import org.openscience.cdk.fingerprint.HybridizationFingerprinter;
+import org.openscience.cdk.fingerprint.IFingerprinter;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IMoleculeSet;
-import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IRingSet;
import org.openscience.cdk.io.MDLV2000Writer;
import org.openscience.cdk.io.iterator.IteratingMDLReader;
@@ -55,8 +56,8 @@
/**
* Helper class that help setup a template library of CDK's Builder3D.
*
- * @author Christian Hoppe.
- * @cdk.module builder3dtools
+ * @author Christian Hoppe
+ * @cdk.module builder3dtools
* @cdk.githash
*/
public class TemplateExtractor {
@@ -170,10 +171,10 @@ public void extractUniqueRingSystemsFromFile(String dataFile) {
System.out.println("From file:" + dataFile);
IMolecule m = null;
// RingPartitioner ringPartitioner=new RingPartitioner();
- List ringSystems = null;
+ List<IRingSet> ringSystems = null;
IteratingMDLReader imdl = null;
- HashMap HashRingSystems = new HashMap();
+ HashMap<String,String> hashRingSystems = new HashMap<String,String>();
SmilesGenerator smilesGenerator = new SmilesGenerator();
int counterRings = 0;
@@ -224,7 +225,7 @@ public void extractUniqueRingSystemsFromFile(String dataFile) {
for (int i = 0; i < ringSystems.size(); i++) {
ringSet = (IRingSet) ringSystems.get(i);
ac = builder.newInstance(IAtomContainer.class);
- Iterator containers = RingSetManipulator.getAllAtomContainers(ringSet).iterator();
+ Iterator<IAtomContainer> containers = RingSetManipulator.getAllAtomContainers(ringSet).iterator();
while (containers.hasNext()) {
ac.add((IAtomContainer)containers.next());
}
@@ -237,7 +238,7 @@ public void extractUniqueRingSystemsFromFile(String dataFile) {
key = smilesGenerator.createSMILES(builder.newInstance(IMolecule.class,ac));
// System.out.println("OrgKey:"+key+" For
// Molecule:"+counter);
- if (HashRingSystems.containsKey(key)) {
+ if (hashRingSystems.containsKey(key)) {
// System.out.println("HAS KEY:ADD");
// Vector tmp=(Vector)HashRingSystems.get(key);
// tmp.add((AtomContainer)ringSet.getRingSetInAtomContainer());
@@ -250,7 +251,7 @@ public void extractUniqueRingSystemsFromFile(String dataFile) {
counterUniqueRings = counterUniqueRings + 1;
// Vector rings2=new Vector();
// rings2.add((AtomContainer)RingSetManipulator.getAllInOneContainer(ringSet));
- HashRingSystems.put(key, new String("1"));
+ hashRingSystems.put(key, new String("1"));
try {
// mdlw.write(new Molecule
// ((AtomContainer)RingSetManipulator.getAllInOneContainer(ringSet)));
@@ -274,7 +275,7 @@ public void extractUniqueRingSystemsFromFile(String dataFile) {
System.out.println("READY Molecules:" + counterMolecules
+ " RingSystems:" + counterRings + " UniqueRingsSystem:"
+ counterUniqueRings);
- System.out.println("HashtableKeys:" + HashRingSystems.size());
+ System.out.println("HashtableKeys:" + hashRingSystems.size());
/*
* int c=0; Set keyset = HashRingSystems.keySet(); Iterator
@@ -311,7 +312,7 @@ public void makeCanonicalSmileFromRingSystems(String dataFileIn,
IMolecule m = null;
IteratingMDLReader imdl = null;
// QueryAtomContainer query=null;
- List data = new ArrayList();
+ List<String> data = new ArrayList<String>();
SmilesGenerator smiles = new SmilesGenerator();
try {
System.out.println("Start...");
@@ -372,7 +373,8 @@ public void makeCanonicalSmileFromRingSystems(String dataFileIn,
}
}
- public List makeFingerprintsFromSdf(boolean anyAtom, boolean anyAtomAnyBond, Map timings, BufferedReader fin, int limit) throws Exception{
+ public List<BitSet> makeFingerprintsFromSdf(boolean anyAtom, boolean anyAtomAnyBond,
+ Map<String,Integer> timings, BufferedReader fin, int limit) throws Exception {
AllRingsFinder allRingsFinder = new AllRingsFinder();
allRingsFinder.setTimeout(10000); // 10 seconds
@@ -464,12 +466,12 @@ public List makeFingerprintsFromSdf(boolean anyAtom, boolean anyAtomAnyBond, Map
public void makeFingerprintFromRingSystems(String dataFileIn,
String dataFileOut, boolean anyAtom, boolean anyAtomAnyBond)
throws Exception {
- Map timings = new HashMap();
+ Map<String,Integer> timings = new HashMap<String,Integer>();
System.out.println("Start make fingerprint from file:" + dataFileIn
+ " ...");
BufferedReader fin = new BufferedReader(new FileReader(dataFileIn));
- List data=makeFingerprintsFromSdf(anyAtom, anyAtomAnyBond, timings, fin,-1);
+ List<BitSet> data = makeFingerprintsFromSdf(anyAtom, anyAtomAnyBond, timings, fin,-1);
BufferedWriter fout = null;
try {
fout = new BufferedWriter(new FileWriter(dataFileOut));
@@ -479,7 +481,7 @@ public void makeFingerprintFromRingSystems(String dataFileIn,
}
for (int i = 0; i < data.size(); i++) {
try {
- fout.write(((BitSet) data.get(i)).toString());
+ fout.write(data.get(i).toString());
fout.newLine();
} catch (Exception exc4) {
}
10 src/main/org/openscience/cdk/modeling/builder3d/TemplateHandler3D.java
View
@@ -164,15 +164,15 @@ public static BitSet getBitSetFromFile(StringTokenizer st) throws Exception {
*@param ringSystems RingSystems of a molecule
*@return The largestRingSet
*/
- public IRingSet getLargestRingSet(List ringSystems) {
+ public IRingSet getLargestRingSet(List<IRingSet> ringSystems) {
IRingSet largestRingSet = null;
int atomNumber = 0;
IAtomContainer container = null;
for (int i = 0; i < ringSystems.size(); i++) {
- container = getAllInOneContainer((IRingSet) ringSystems.get(i));
+ container = getAllInOneContainer(ringSystems.get(i));
if (atomNumber < container.getAtomCount()) {
atomNumber = container.getAtomCount();
- largestRingSet = (IRingSet) ringSystems.get(i);
+ largestRingSet = ringSystems.get(i);
}
}
return largestRingSet;
@@ -180,7 +180,7 @@ public IRingSet getLargestRingSet(List ringSystems) {
private IAtomContainer getAllInOneContainer(IRingSet ringSet) {
IAtomContainer resultContainer = ringSet.getBuilder().newInstance(IAtomContainer.class);
- Iterator containers = RingSetManipulator.getAllAtomContainers(ringSet).iterator();
+ Iterator<IAtomContainer> containers = RingSetManipulator.getAllAtomContainers(ringSet).iterator();
while (containers.hasNext()) {
resultContainer.add((IAtomContainer) containers.next());
}
@@ -215,7 +215,7 @@ public void mapTemplates(IAtomContainer ringSystems, double NumberOfRingAtoms) t
//we do the exact match with any atom and any bond
if (UniversalIsomorphismTester.isSubgraph(ringSystemAnyBondAnyAtom, templateAnyBondAnyAtom)) {
//if this is the case, we keep it as a guess, but look if we can do better
- List list = UniversalIsomorphismTester.getSubgraphAtomsMap(ringSystemAnyBondAnyAtom, templateAnyBondAnyAtom);
+ List<RMap> list = UniversalIsomorphismTester.getSubgraphAtomsMap(ringSystemAnyBondAnyAtom, templateAnyBondAnyAtom);
boolean flagwritefromsecondbest=false;
if ((NumberOfRingAtoms) / list.size() == 1 && templateAnyBondAnyAtom.getBondCount()==ringSystems.getBondCount()) {
//so atom and bond count match, could be it's even an exact match,
Please sign in to comment.
Something went wrong with that request. Please try again.