Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Confirm atom signatures are same size as atoms

  • Loading branch information...
commit 1dfa9b1bcbdf96bbcb7009dfb11bad93280a6a29 1 parent 3b0481e
@olas authored
View
61 plugins/net.bioclipse.ds.signatures/src/net/bioclipse/ds/signatures/business/SignaturesManager.java
@@ -13,6 +13,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -71,21 +72,38 @@ public AtomSignatures generate(IMolecule mol, int height)
throws BioclipseException{
//Adapt IMolecule to ICDKMolecule
- ICDKManager cdk = Activator.getDefault().getJavaCDKManager();
- ICDKMolecule cdkmol = cdk.asCDKMolecule(mol);
-
+ ICDKManager cdk = Activator.getDefault().getJavaCDKManager();
+ ICDKMolecule cdkmol = cdk.asCDKMolecule(mol);
+
Molecule signmol = CDKMoleculeSignatureAdapter.convert(cdkmol.getAtomContainer());
+
+ List<String> signatureString=new ArrayList<String>();
+
+ MoleculeSignature signature = new MoleculeSignature(signmol);
+ for ( int atomNr = 0; atomNr < signmol.getAtomCount(); atomNr++){
+ String gensign=signature.signatureStringForVertex(atomNr, height);
+ if (gensign==null || gensign.isEmpty()){
+ logger.error("Produced null or empty " +
+ "signature for atom: " + atomNr
+ + " in molecule: " + cdkmol);
+ throw new BioclipseException("Produced null or empty " +
+ "signature for atom: " + atomNr
+ + " in molecule: " + cdkmol);
+ }
+
+ signatureString.add( gensign);
+// logger.debug("Sign for atom " + atomNr + ": " +gensign);
+ }
- List<String> signatureString=new ArrayList<String>();
+ //Test correct number of produced signatures (should not be an issue)
+ if (signatureString.size()!=cdkmol.getAtomContainer().getAtomCount())
+ throw new BioclipseException("Number of atoms and atom signatures " +
+ "differ for molecule: " + cdkmol +" ; Number of atoms: " +
+ cdkmol.getAtomContainer().getAtomCount() +
+ " and number of signatures produced: "
+ + signatureString.size());
- MoleculeSignature signature = new MoleculeSignature(signmol);
- for ( int atomNr = 0; atomNr < signmol.getAtomCount(); atomNr++){
- String gensign=signature.signatureStringForVertex(atomNr, height);
- signatureString.add( gensign);
-// logger.debug("Sign for atom " + atomNr + ": " +gensign);
- }
-
- return new AtomSignatures(signatureString);
+ return new AtomSignatures(signatureString);
}
@@ -110,16 +128,25 @@ public AtomSignatures generate(IMolecule mol, int height)
Map<IMolecule, AtomSignatures> retmap =
new HashMap<IMolecule, AtomSignatures>();
+
for (IMolecule mol : mols){
try {
- AtomSignatures s = generate( mol , height);
- if (s.getSignatures() !=null && s.getSignatures().size()>0)
- retmap.put( mol, s );
+ AtomSignatures as = generate( mol , height);
+
+ if (as.getSignatures() == null || as.getSignatures().size()<=0)
+ logger.error( "No signatures generated for for molecule: "
+ + mol + ". Skipping this entry." );
+ else
+ //All is well
+ retmap.put( mol, as );
+
+
} catch ( BioclipseException e ) {
logger.error( "Error generating signatures for molecule: "
- + mol + ". Skipping this entry." );
+ + mol + ". Skipping this entry. " +
+ "Reason: " + e.getMessage() );
}
-
+
}
return retmap;
Please sign in to comment.
Something went wrong with that request. Please try again.