summaryrefslogtreecommitdiff
path: root/java/JoelibDescriptors.java
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2015-08-15 11:52:18 +0200
committerChristoph Helma <helma@in-silico.ch>2015-08-15 11:52:18 +0200
commit9a5b7b1bfb352b3a6555babe8bc2344414f66185 (patch)
tree52546698cd6f77ce72bfc0684021f3f439a4496d /java/JoelibDescriptors.java
parent81a2454a9abde6bb79793eb4c72e4a8725f5fe7f (diff)
java libraries added
Diffstat (limited to 'java/JoelibDescriptors.java')
-rw-r--r--java/JoelibDescriptors.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/java/JoelibDescriptors.java b/java/JoelibDescriptors.java
new file mode 100644
index 0000000..e90e35f
--- /dev/null
+++ b/java/JoelibDescriptors.java
@@ -0,0 +1,60 @@
+import java.util.*;
+import java.io.*;
+import joelib2.feature.Feature;
+import joelib2.feature.FeatureHelper;
+import joelib2.feature.FeatureFactory;
+import joelib2.feature.FeatureResult;
+import joelib2.io.BasicIOType;
+import joelib2.io.BasicIOTypeHolder;
+import joelib2.io.BasicReader;
+import joelib2.io.MoleculeFileHelper;
+import joelib2.io.MoleculeFileIO;
+import joelib2.io.MoleculeIOException;
+import joelib2.molecule.BasicConformerMolecule;
+
+class JoelibDescriptors {
+ public static void main(String[] args) {
+
+ String[] features = null;
+ features = new String[args.length-1];
+ System.arraycopy(args,1,features,0,args.length-1);
+
+ FeatureFactory factory = FeatureFactory.instance();
+ MoleculeFileIO loader = null;
+ String line = new String();
+ String sdf = new String();
+ try {
+ // parse 3d sdf from file and calculate descriptors
+ InputStream is = new FileInputStream(args[0]);
+ PrintWriter yaml = new PrintWriter(new FileWriter(args[0]+"joelib.yaml"));
+ BasicIOType inType = BasicIOTypeHolder.instance().getIOType("SDF");
+ loader = MoleculeFileHelper.getMolReader(is, inType);
+ BasicConformerMolecule mol = new BasicConformerMolecule(inType, inType);
+ while (true) {
+ try {
+ Boolean success = loader.read(mol);
+ if (!success) { break; } // last molecule
+ for (int i =0; i < features.length; i++) {
+ String name = "joelib2.feature.types." + features[i];
+ Feature feature = factory.getFeature(name);
+ FeatureResult result = feature.calculate(mol);
+ if (i == 0) { yaml.print("- "); }
+ else { yaml.print(" "); }
+ yaml.print( "Joelib."+features[i]+": " );
+ yaml.println( result.toString() );
+ }
+
+ }
+ catch (Exception e) {
+ System.err.println(e.toString());
+ e.printStackTrace();
+ }
+ }
+ yaml.close();
+ }
+ catch (Exception e) {
+ System.err.println(e.toString());
+ e.printStackTrace();
+ }
+ }
+}