Fandom

Chemistry Toolkit Rosetta Wiki

Iteration through an SD file

21pages on
this wiki
Add New Page
Talk0 Share

CDK/JythonEdit

copied from http://www.redbrick.dcu.ie/~noel/CDKJython.html The original author is Noel O'Boyle.

 from org.openscience.cdk import *
 from org.openscience.cdk.qsar.descriptors.molecular import BCUTDescriptor
 from org.openscience.cdk.io.iterator import IteratingMDLReader
 
 from java.io import InputStreamReader
 
 import sys
 
 '''try''':
     sdfile=open(sys.argv[1],"r")
 '''except''' (IOError,IndexError):
     '''print''' "You need to give the name of an existing .sd file"
     sys.exit(1)
 
 bcut=BCUTDescriptor()
 bcut.setParameters([1,1])
 '''for''' mol '''in''' IteratingMDLReader( InputStreamReader(sdfile)):
     BCUTvalue=bcut.calculate(mol).getValue()
     # Create list of values in BCUTvalue
     BCUTlist=[str(BCUTvalue.get(i)) '''for''' i '''in''' range(6)]
     # Concatenate BCUTlist around tabs
     '''print''' "\t".join(BCUTlist)

CDK/JavaEdit

from CDK java document http://pele.farmbio.uu.se/nightly/api/org/openscience/cdk/io/iterator/IteratingMDLReader.html

 File sdfFile = new File("../zinc-structures/ZINC_subset3_3D_charged_wH_maxmin1000.sdf");
 IteratingMDLReader reader = new IteratingMDLReader(
   new FileInputStream(sdfFile), NewDefaultChemObjectBuilder.getInstance()
 );
 while (reader.hasNext()) {
   IMolecule molecule = (IMolecule)reader.next();
 }

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.