summaryrefslogtreecommitdiff
path: root/java/JoelibDescriptors.java
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2015-10-08 10:43:43 +0200
committerChristoph Helma <helma@in-silico.ch>2015-10-08 10:43:43 +0200
commit1a56148aadef031c4f487bc23fda43f4ac5b7369 (patch)
tree3555c5883ed0c292b105c40c185ebba3e5bd4e3e /java/JoelibDescriptors.java
parent394d564699756288569169ff3e198d6d7702f092 (diff)
parente3217075b602a950a0ee995fcfa731d97b5ba3eb (diff)
new master branch
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();
+ }
+ }
+}