Advertisement
jonalv

Groovy Bioclipse script

Sep 8th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.97 KB | None | 0 0
  1. // To run in Bioclipse groovy console write:
  2. // evaluate(ui.readFile("/Bioclipse_project_MM/makeSmilesFile.groovy"))
  3.  
  4. dataIn = new java.net.URL("platform:/resource/Bioclipse_project_MM/solubilityData.csv")
  5. smilesIn = new java.net.URL("platform:/resource/Bioclipse_project_MM/solubilitySMILES.txt")
  6.  
  7. def map = new java.util.HashMap();
  8.  
  9. ( dataIn.openStream() ).eachLine { line ->
  10.     sid = line.split(",")[0];
  11.     sol = line.split(",")[7];
  12.     if (map.containsKey(sid)) {
  13.         print("Found " + sid + " twice");
  14.     }
  15.     map.put(sid, sol)
  16. }
  17.  
  18. file = new File( ui.newFile("Bioclipse_project_MM/solubility.smi").getRawLocation().toString() )
  19. i = 0
  20. ( smilesIn.openStream() ).eachLine { line ->
  21.     sid = line.split("\t")[0];
  22.     SMILES = line.split("\t")[1];
  23.  
  24.     file << (SMILES + ", " + ( Double.parseDouble(map.get(sid)) / cdk.calculateMass(cdk.fromSMILES(SMILES) ) / 1000) + "\n");
  25.     if ( ++i%100 == 0 ) {
  26.         print(i + " Done. \n");
  27.     }
  28. }
  29. print("All Done.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement