Files
openbabel/scripts/python/pybelapi.html
2007-09-03 20:53:06 +00:00

394 lines
24 KiB
HTML

<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module pybel</title>
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>pybel</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/user/Tools/openbabel-2-1-xz/scripts/python/pybel.py">/home/user/Tools/openbabel-2-1-xz/scripts/python/pybel.py</a></font></td></tr></table>
<p></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="openbabel.html">openbabel</a><br>
</td><td width="25%" valign=top><a href="os.html">os</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="pybel.html#Atom">Atom</a>
</font></dt><dt><font face="helvetica, arial"><a href="pybel.html#Fingerprint">Fingerprint</a>
</font></dt><dt><font face="helvetica, arial"><a href="pybel.html#Molecule">Molecule</a>
</font></dt><dt><font face="helvetica, arial"><a href="pybel.html#MoleculeData">MoleculeData</a>
</font></dt><dt><font face="helvetica, arial"><a href="pybel.html#Outputfile">Outputfile</a>
</font></dt><dt><font face="helvetica, arial"><a href="pybel.html#Smarts">Smarts</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Atom">class <strong>Atom</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Represent&nbsp;a&nbsp;Pybel&nbsp;atom.<br>
&nbsp;<br>
Optional&nbsp;parameters:<br>
&nbsp;&nbsp;&nbsp;OBAtom&nbsp;--&nbsp;an&nbsp;Open&nbsp;Babel&nbsp;<a href="#Atom">Atom</a>&nbsp;(default&nbsp;is&nbsp;None)<br>
&nbsp;&nbsp;&nbsp;index&nbsp;--&nbsp;the&nbsp;index&nbsp;of&nbsp;the&nbsp;atom&nbsp;in&nbsp;the&nbsp;molecule&nbsp;(default&nbsp;is&nbsp;None)<br>
&nbsp;<br>
An&nbsp;empty&nbsp;<a href="#Atom">Atom</a>&nbsp;is&nbsp;created&nbsp;if&nbsp;an&nbsp;Open&nbsp;Babel&nbsp;atom&nbsp;is&nbsp;not&nbsp;provided.<br>
&nbsp;<br>
Attributes:<br>
&nbsp;&nbsp;&nbsp;atomicmass,&nbsp;atomicnum,&nbsp;cidx,&nbsp;coords,&nbsp;coordidx,&nbsp;exactmass,<br>
&nbsp;&nbsp;&nbsp;formalcharge,&nbsp;heavyvalence,&nbsp;heterovalence,&nbsp;hyb,&nbsp;idx,<br>
&nbsp;&nbsp;&nbsp;implicitvalence,&nbsp;index,&nbsp;isotope,&nbsp;partialcharge,&nbsp;spin,&nbsp;type,<br>
&nbsp;&nbsp;&nbsp;valence,&nbsp;vector.<br>
&nbsp;<br>
(refer&nbsp;to&nbsp;the&nbsp;Open&nbsp;Babel&nbsp;library&nbsp;documentation&nbsp;for&nbsp;more&nbsp;info).<br>
&nbsp;<br>
The&nbsp;original&nbsp;Open&nbsp;Babel&nbsp;atom&nbsp;can&nbsp;be&nbsp;accessed&nbsp;using&nbsp;the&nbsp;attribute:<br>
&nbsp;&nbsp;&nbsp;OBAtom<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Atom-__getattr__"><strong>__getattr__</strong></a>(self, attr)</dt></dl>
<dl><dt><a name="Atom-__init__"><strong>__init__</strong></a>(self, OBAtom<font color="#909090">=None</font>, index<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="Atom-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>Create&nbsp;a&nbsp;string&nbsp;representation&nbsp;of&nbsp;the&nbsp;atom.<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;a&nbsp;=&nbsp;<a href="#Atom">Atom</a>()<br>
&gt;&gt;&gt;&nbsp;print&nbsp;a<br>
<a href="#Atom">Atom</a>:&nbsp;0&nbsp;(0.0,&nbsp;0.0,&nbsp;0.0)</tt></dd></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>__dict__</strong> = &lt;dictproxy object&gt;<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dl>
<dl><dt><strong>__weakref__</strong> = &lt;attribute '__weakref__' of 'Atom' objects&gt;<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;(if&nbsp;defined)</tt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Fingerprint">class <strong>Fingerprint</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>A&nbsp;Molecular&nbsp;<a href="#Fingerprint">Fingerprint</a>.<br>
&nbsp;<br>
Required&nbsp;parameters:<br>
&nbsp;&nbsp;&nbsp;obFingerprint&nbsp;--&nbsp;a&nbsp;vector&nbsp;calculated&nbsp;by&nbsp;OBFingerprint.FindFingerprint()<br>
&nbsp;<br>
Attributes:<br>
&nbsp;&nbsp;&nbsp;fp&nbsp;--&nbsp;the&nbsp;original&nbsp;obFingerprint<br>
&nbsp;&nbsp;&nbsp;bits&nbsp;--&nbsp;a&nbsp;list&nbsp;of&nbsp;bits&nbsp;set&nbsp;in&nbsp;the&nbsp;<a href="#Fingerprint">Fingerprint</a><br>
&nbsp;<br>
Methods:<br>
&nbsp;&nbsp;&nbsp;The&nbsp;"|"&nbsp;operator&nbsp;can&nbsp;be&nbsp;used&nbsp;to&nbsp;calculate&nbsp;the&nbsp;Tanimoto&nbsp;coeff.&nbsp;For&nbsp;example,<br>
&nbsp;&nbsp;&nbsp;given&nbsp;two&nbsp;Fingerprints&nbsp;'a',&nbsp;and&nbsp;'b',&nbsp;the&nbsp;Tanimoto&nbsp;coefficient&nbsp;is&nbsp;given&nbsp;by:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tanimoto&nbsp;=&nbsp;a&nbsp;|&nbsp;b<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Fingerprint-__getattr__"><strong>__getattr__</strong></a>(self, attr)</dt></dl>
<dl><dt><a name="Fingerprint-__init__"><strong>__init__</strong></a>(self, obFingerprint)</dt></dl>
<dl><dt><a name="Fingerprint-__or__"><strong>__or__</strong></a>(self, other)</dt></dl>
<dl><dt><a name="Fingerprint-__str__"><strong>__str__</strong></a>(self)</dt></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>__dict__</strong> = &lt;dictproxy object&gt;<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dl>
<dl><dt><strong>__weakref__</strong> = &lt;attribute '__weakref__' of 'Fingerprint' objects&gt;<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;(if&nbsp;defined)</tt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Molecule">class <strong>Molecule</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Represent&nbsp;a&nbsp;Pybel&nbsp;molecule.<br>
&nbsp;<br>
Optional&nbsp;parameters:<br>
&nbsp;&nbsp;&nbsp;OBMol&nbsp;--&nbsp;an&nbsp;Open&nbsp;Babel&nbsp;molecule&nbsp;(default&nbsp;is&nbsp;None)<br>
&nbsp;<br>
An&nbsp;empty&nbsp;<a href="#Molecule">Molecule</a>&nbsp;is&nbsp;created&nbsp;if&nbsp;an&nbsp;Open&nbsp;Babel&nbsp;molecule&nbsp;is&nbsp;not&nbsp;provided.<br>
&nbsp;<br>
Attributes:<br>
&nbsp;&nbsp;&nbsp;atoms,&nbsp;charge,&nbsp;data,&nbsp;dim,&nbsp;energy,&nbsp;exactmass,&nbsp;flags,&nbsp;formula,&nbsp;<br>
&nbsp;&nbsp;&nbsp;mod,&nbsp;molwt,&nbsp;spin,&nbsp;sssr,&nbsp;title,&nbsp;unitcell.<br>
(refer&nbsp;to&nbsp;the&nbsp;Open&nbsp;Babel&nbsp;library&nbsp;documentation&nbsp;for&nbsp;more&nbsp;info).<br>
&nbsp;<br>
Methods:<br>
&nbsp;&nbsp;&nbsp;<a href="#Molecule-write">write</a>(),&nbsp;<a href="#Molecule-calcfp">calcfp</a>(),&nbsp;<a href="#Molecule-calcdesc">calcdesc</a>()<br>
&nbsp;&nbsp;<br>
The&nbsp;original&nbsp;Open&nbsp;Babel&nbsp;molecule&nbsp;can&nbsp;be&nbsp;accessed&nbsp;using&nbsp;the&nbsp;attribute:<br>
&nbsp;&nbsp;&nbsp;OBMol<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Molecule-__getattr__"><strong>__getattr__</strong></a>(self, attr)</dt><dd><tt>Return&nbsp;the&nbsp;value&nbsp;of&nbsp;an&nbsp;attribute<br>
&nbsp;<br>
Note:&nbsp;The&nbsp;values&nbsp;are&nbsp;calculated&nbsp;on-the-fly.&nbsp;You&nbsp;may&nbsp;want&nbsp;to&nbsp;store&nbsp;the&nbsp;value&nbsp;in<br>
a&nbsp;variable&nbsp;if&nbsp;you&nbsp;repeatedly&nbsp;access&nbsp;the&nbsp;same&nbsp;attribute.</tt></dd></dl>
<dl><dt><a name="Molecule-__init__"><strong>__init__</strong></a>(self, OBMol<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="Molecule-__iter__"><strong>__iter__</strong></a>(self)</dt><dd><tt>Iterate&nbsp;over&nbsp;the&nbsp;Atoms&nbsp;of&nbsp;the&nbsp;<a href="#Molecule">Molecule</a>.<br>
&nbsp;<br>
This&nbsp;allows&nbsp;constructions&nbsp;such&nbsp;as&nbsp;the&nbsp;following:<br>
&nbsp;&nbsp;&nbsp;for&nbsp;atom&nbsp;in&nbsp;mymol:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;atom</tt></dd></dl>
<dl><dt><a name="Molecule-__str__"><strong>__str__</strong></a>(self)</dt></dl>
<dl><dt><a name="Molecule-calcdesc"><strong>calcdesc</strong></a>(self, descnames<font color="#909090">=[]</font>)</dt><dd><tt>Calculate&nbsp;descriptor&nbsp;values.<br>
&nbsp;<br>
Optional&nbsp;parameter:<br>
&nbsp;&nbsp;&nbsp;descnames&nbsp;--&nbsp;a&nbsp;list&nbsp;of&nbsp;names&nbsp;of&nbsp;descriptors<br>
&nbsp;<br>
If&nbsp;descnames&nbsp;is&nbsp;not&nbsp;specified,&nbsp;the&nbsp;full&nbsp;list&nbsp;of&nbsp;Open&nbsp;Babel<br>
descriptors&nbsp;is&nbsp;calculated:&nbsp;LogP,&nbsp;PSA&nbsp;and&nbsp;MR.</tt></dd></dl>
<dl><dt><a name="Molecule-calcfp"><strong>calcfp</strong></a>(self, fptype<font color="#909090">=''</font>)</dt><dd><tt>Calculate&nbsp;a&nbsp;molecular&nbsp;fingerprint.<br>
&nbsp;<br>
Optional&nbsp;parameters:<br>
&nbsp;&nbsp;&nbsp;fptype&nbsp;--&nbsp;the&nbsp;name&nbsp;of&nbsp;the&nbsp;Open&nbsp;Babel&nbsp;fingerprint&nbsp;type.<br>
&nbsp;<br>
If&nbsp;fptype&nbsp;is&nbsp;not&nbsp;specified,&nbsp;the&nbsp;default&nbsp;Open&nbsp;Babel&nbsp;fingerprint<br>
type&nbsp;is&nbsp;used.&nbsp;See&nbsp;the&nbsp;Open&nbsp;Babel&nbsp;library&nbsp;documentation&nbsp;for&nbsp;more<br>
details.</tt></dd></dl>
<dl><dt><a name="Molecule-write"><strong>write</strong></a>(self, format<font color="#909090">='SMI'</font>, filename<font color="#909090">=None</font>, overwrite<font color="#909090">=False</font>)</dt><dd><tt>Write&nbsp;the&nbsp;molecule&nbsp;to&nbsp;a&nbsp;file&nbsp;or&nbsp;return&nbsp;a&nbsp;string.<br>
&nbsp;<br>
Optional&nbsp;parameters:<br>
&nbsp;&nbsp;&nbsp;format&nbsp;--&nbsp;default&nbsp;is&nbsp;"SMI"<br>
&nbsp;&nbsp;&nbsp;filename&nbsp;--&nbsp;default&nbsp;is&nbsp;None<br>
&nbsp;&nbsp;&nbsp;overwite&nbsp;--&nbsp;default&nbsp;is&nbsp;False<br>
&nbsp;<br>
If&nbsp;a&nbsp;filename&nbsp;is&nbsp;specified,&nbsp;the&nbsp;result&nbsp;is&nbsp;written&nbsp;to&nbsp;a&nbsp;file.<br>
Otherwise,&nbsp;a&nbsp;string&nbsp;is&nbsp;returned&nbsp;containing&nbsp;the&nbsp;result.<br>
The&nbsp;overwrite&nbsp;flag&nbsp;is&nbsp;ignored&nbsp;if&nbsp;a&nbsp;filename&nbsp;is&nbsp;not&nbsp;specified.<br>
It&nbsp;controls&nbsp;whether&nbsp;to&nbsp;overwrite&nbsp;an&nbsp;existing&nbsp;file.</tt></dd></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>__dict__</strong> = &lt;dictproxy object&gt;<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dl>
<dl><dt><strong>__weakref__</strong> = &lt;attribute '__weakref__' of 'Molecule' objects&gt;<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;(if&nbsp;defined)</tt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="MoleculeData">class <strong>MoleculeData</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Store&nbsp;molecule&nbsp;data&nbsp;in&nbsp;a&nbsp;dictionary-type&nbsp;<a href="__builtin__.html#object">object</a><br>
&nbsp;<br>
Required&nbsp;parameters:<br>
&nbsp;&nbsp;obmol&nbsp;--&nbsp;an&nbsp;Open&nbsp;Babel&nbsp;OBMol&nbsp;<br>
&nbsp;<br>
Methods&nbsp;and&nbsp;accessor&nbsp;methods&nbsp;are&nbsp;like&nbsp;those&nbsp;of&nbsp;a&nbsp;dictionary&nbsp;except<br>
that&nbsp;the&nbsp;data&nbsp;is&nbsp;retrieved&nbsp;on-the-fly&nbsp;from&nbsp;the&nbsp;underlying&nbsp;OBMol.<br>
&nbsp;<br>
Example:<br>
&gt;&gt;&gt;&nbsp;mol&nbsp;=&nbsp;<a href="#-readfile">readfile</a>("sdf",&nbsp;'head.sdf').next()<br>
&gt;&gt;&gt;&nbsp;data&nbsp;=&nbsp;mol.data<br>
&gt;&gt;&gt;&nbsp;print&nbsp;data<br>
{'Comment':&nbsp;'CORINA&nbsp;2.61&nbsp;0041&nbsp;&nbsp;25.10.2001',&nbsp;'NSC':&nbsp;'1'}<br>
&gt;&gt;&gt;&nbsp;print&nbsp;len(data),&nbsp;data.<a href="#MoleculeData-keys">keys</a>(),&nbsp;data.<a href="#MoleculeData-has_key">has_key</a>("NSC")<br>
2&nbsp;['Comment',&nbsp;'NSC']&nbsp;True<br>
&gt;&gt;&gt;&nbsp;print&nbsp;data['Comment']<br>
CORINA&nbsp;2.61&nbsp;0041&nbsp;&nbsp;25.10.2001<br>
&gt;&gt;&gt;&nbsp;data['Comment']&nbsp;=&nbsp;'This&nbsp;is&nbsp;a&nbsp;new&nbsp;comment'<br>
&gt;&gt;&gt;&nbsp;for&nbsp;k,v&nbsp;in&nbsp;data.<a href="#MoleculeData-iteritems">iteritems</a>():<br>
...&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;k,&nbsp;"--&gt;",&nbsp;v<br>
Comment&nbsp;--&gt;&nbsp;This&nbsp;is&nbsp;a&nbsp;new&nbsp;comment<br>
NSC&nbsp;--&gt;&nbsp;1<br>
&gt;&gt;&gt;&nbsp;del&nbsp;data['NSC']<br>
&gt;&gt;&gt;&nbsp;print&nbsp;len(data),&nbsp;data.<a href="#MoleculeData-keys">keys</a>(),&nbsp;data.<a href="#MoleculeData-has_key">has_key</a>("NSC")<br>
1&nbsp;['Comment']&nbsp;False<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="MoleculeData-__contains__"><strong>__contains__</strong></a>(self, key)</dt></dl>
<dl><dt><a name="MoleculeData-__delitem__"><strong>__delitem__</strong></a>(self, key)</dt></dl>
<dl><dt><a name="MoleculeData-__getitem__"><strong>__getitem__</strong></a>(self, key)</dt></dl>
<dl><dt><a name="MoleculeData-__init__"><strong>__init__</strong></a>(self, obmol)</dt></dl>
<dl><dt><a name="MoleculeData-__iter__"><strong>__iter__</strong></a>(self)</dt></dl>
<dl><dt><a name="MoleculeData-__len__"><strong>__len__</strong></a>(self)</dt></dl>
<dl><dt><a name="MoleculeData-__repr__"><strong>__repr__</strong></a>(self)</dt></dl>
<dl><dt><a name="MoleculeData-__setitem__"><strong>__setitem__</strong></a>(self, key, value)</dt></dl>
<dl><dt><a name="MoleculeData-clear"><strong>clear</strong></a>(self)</dt></dl>
<dl><dt><a name="MoleculeData-has_key"><strong>has_key</strong></a>(self, key)</dt></dl>
<dl><dt><a name="MoleculeData-items"><strong>items</strong></a>(self)</dt></dl>
<dl><dt><a name="MoleculeData-iteritems"><strong>iteritems</strong></a>(self)</dt></dl>
<dl><dt><a name="MoleculeData-keys"><strong>keys</strong></a>(self)</dt></dl>
<dl><dt><a name="MoleculeData-update"><strong>update</strong></a>(self, dictionary)</dt></dl>
<dl><dt><a name="MoleculeData-values"><strong>values</strong></a>(self)</dt></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>__dict__</strong> = &lt;dictproxy object&gt;<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dl>
<dl><dt><strong>__weakref__</strong> = &lt;attribute '__weakref__' of 'MoleculeData' objects&gt;<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;(if&nbsp;defined)</tt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Outputfile">class <strong>Outputfile</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Represent&nbsp;a&nbsp;file&nbsp;to&nbsp;which&nbsp;*output*&nbsp;is&nbsp;to&nbsp;be&nbsp;sent.<br>
&nbsp;<br>
Although&nbsp;it's&nbsp;possible&nbsp;to&nbsp;write&nbsp;a&nbsp;single&nbsp;molecule&nbsp;to&nbsp;a&nbsp;file&nbsp;by<br>
calling&nbsp;the&nbsp;<a href="#Outputfile-write">write</a>()&nbsp;method&nbsp;of&nbsp;a&nbsp;molecule,&nbsp;if&nbsp;multiple&nbsp;molecules<br>
are&nbsp;to&nbsp;be&nbsp;written&nbsp;to&nbsp;the&nbsp;same&nbsp;file&nbsp;you&nbsp;should&nbsp;use&nbsp;the&nbsp;<a href="#Outputfile">Outputfile</a><br>
class.<br>
&nbsp;<br>
Required&nbsp;parameters:<br>
&nbsp;&nbsp;&nbsp;format<br>
&nbsp;&nbsp;&nbsp;filename<br>
Optional&nbsp;parameters:<br>
&nbsp;&nbsp;&nbsp;overwrite&nbsp;(default&nbsp;is&nbsp;False)&nbsp;--&nbsp;if&nbsp;the&nbsp;output&nbsp;file&nbsp;already&nbsp;exists,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;should&nbsp;it&nbsp;be&nbsp;overwritten?<br>
Methods:<br>
&nbsp;&nbsp;&nbsp;<a href="#Outputfile-write">write</a>(molecule)<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Outputfile-__init__"><strong>__init__</strong></a>(self, format, filename, overwrite<font color="#909090">=False</font>)</dt></dl>
<dl><dt><a name="Outputfile-close"><strong>close</strong></a>(self)</dt><dd><tt>Close&nbsp;the&nbsp;<a href="#Outputfile">Outputfile</a>&nbsp;to&nbsp;further&nbsp;writing.</tt></dd></dl>
<dl><dt><a name="Outputfile-write"><strong>write</strong></a>(self, molecule)</dt><dd><tt>Write&nbsp;a&nbsp;molecule&nbsp;to&nbsp;the&nbsp;output&nbsp;file.<br>
&nbsp;<br>
Required&nbsp;parameters:<br>
&nbsp;&nbsp;&nbsp;molecule</tt></dd></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>__dict__</strong> = &lt;dictproxy object&gt;<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dl>
<dl><dt><strong>__weakref__</strong> = &lt;attribute '__weakref__' of 'Outputfile' objects&gt;<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;(if&nbsp;defined)</tt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Smarts">class <strong>Smarts</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>A&nbsp;<a href="#Smarts">Smarts</a>&nbsp;Pattern&nbsp;Matcher<br>
&nbsp;<br>
Required&nbsp;parameters:<br>
&nbsp;&nbsp;&nbsp;smartspattern<br>
&nbsp;<br>
Methods:<br>
&nbsp;&nbsp;&nbsp;<a href="#Smarts-findall">findall</a>()<br>
&nbsp;<br>
Example:<br>
&gt;&gt;&gt;&nbsp;mol&nbsp;=&nbsp;<a href="#-readstring">readstring</a>("smi","CCN(CC)CC")&nbsp;#&nbsp;triethylamine<br>
&gt;&gt;&gt;&nbsp;smarts&nbsp;=&nbsp;<a href="#Smarts">Smarts</a>("[#6][#6]")&nbsp;#&nbsp;Matches&nbsp;an&nbsp;ethyl&nbsp;group<br>
&gt;&gt;&gt;&nbsp;print&nbsp;smarts.<a href="#Smarts-findall">findall</a>(mol)&nbsp;<br>
[(1,&nbsp;2),&nbsp;(4,&nbsp;5),&nbsp;(6,&nbsp;7)]<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Smarts-__init__"><strong>__init__</strong></a>(self, smartspattern)</dt><dd><tt>Initialise&nbsp;with&nbsp;a&nbsp;SMARTS&nbsp;pattern.</tt></dd></dl>
<dl><dt><a name="Smarts-findall"><strong>findall</strong></a>(self, molecule)</dt><dd><tt>Find&nbsp;all&nbsp;matches&nbsp;of&nbsp;the&nbsp;SMARTS&nbsp;pattern&nbsp;to&nbsp;a&nbsp;particular&nbsp;molecule.<br>
&nbsp;<br>
Required&nbsp;parameters:<br>
&nbsp;&nbsp;&nbsp;molecule</tt></dd></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>__dict__</strong> = &lt;dictproxy object&gt;<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dl>
<dl><dt><strong>__weakref__</strong> = &lt;attribute '__weakref__' of 'Smarts' objects&gt;<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;(if&nbsp;defined)</tt></dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-findbits"><strong>findbits</strong></a>(fp, bitsperint)</dt><dd><tt>Find&nbsp;which&nbsp;bits&nbsp;are&nbsp;set&nbsp;in&nbsp;a&nbsp;list/vector.<br>
&nbsp;<br>
This&nbsp;function&nbsp;is&nbsp;used&nbsp;by&nbsp;the&nbsp;<a href="#Fingerprint">Fingerprint</a>&nbsp;class.<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;<a href="#-findbits">findbits</a>([13,&nbsp;71],&nbsp;8)<br>
[1,&nbsp;3,&nbsp;4,&nbsp;9,&nbsp;10,&nbsp;11,&nbsp;15]</tt></dd></dl>
<dl><dt><a name="-readfile"><strong>readfile</strong></a>(format, filename)</dt><dd><tt>Iterate&nbsp;over&nbsp;the&nbsp;molecules&nbsp;in&nbsp;a&nbsp;file.<br>
&nbsp;<br>
Required&nbsp;parameters:<br>
&nbsp;&nbsp;&nbsp;format<br>
&nbsp;&nbsp;&nbsp;filename<br>
&nbsp;<br>
You&nbsp;can&nbsp;access&nbsp;the&nbsp;first&nbsp;molecule&nbsp;in&nbsp;a&nbsp;file&nbsp;using:<br>
&nbsp;&nbsp;&nbsp;&nbsp;mol&nbsp;=&nbsp;<a href="#-readfile">readfile</a>("smi",&nbsp;"myfile.smi").next()<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
You&nbsp;can&nbsp;make&nbsp;a&nbsp;list&nbsp;of&nbsp;the&nbsp;molecules&nbsp;in&nbsp;a&nbsp;file&nbsp;using:<br>
&nbsp;&nbsp;&nbsp;&nbsp;mols&nbsp;=&nbsp;[mol&nbsp;for&nbsp;mol&nbsp;in&nbsp;<a href="#-readfile">readfile</a>("smi",&nbsp;"myfile.smi")]<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
You&nbsp;can&nbsp;iterate&nbsp;over&nbsp;the&nbsp;molecules&nbsp;in&nbsp;a&nbsp;file&nbsp;as&nbsp;shown&nbsp;in&nbsp;the<br>
following&nbsp;code&nbsp;snippet...<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;atomtotal&nbsp;=&nbsp;0<br>
&gt;&gt;&gt;&nbsp;for&nbsp;mol&nbsp;in&nbsp;<a href="#-readfile">readfile</a>("sdf","head.sdf"):<br>
...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;atomtotal&nbsp;+=&nbsp;len(mol.atoms)<br>
...<br>
&gt;&gt;&gt;&nbsp;print&nbsp;atomtotal<br>
43</tt></dd></dl>
<dl><dt><a name="-readstring"><strong>readstring</strong></a>(format, string)</dt><dd><tt>Read&nbsp;in&nbsp;a&nbsp;molecule&nbsp;from&nbsp;a&nbsp;string.<br>
&nbsp;<br>
Required&nbsp;parameters:<br>
&nbsp;&nbsp;&nbsp;format<br>
&nbsp;&nbsp;&nbsp;string<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;input&nbsp;=&nbsp;"C1=CC=CS1"<br>
&gt;&gt;&gt;&nbsp;mymol&nbsp;=&nbsp;<a href="#-readstring">readstring</a>("smi",input)<br>
&gt;&gt;&gt;&nbsp;len(mymol.atoms)<br>
5</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>informats</strong> = {'acr': 'ACR format', 'alc': 'Alchemy format', 'arc': 'Accelrys/MSI Biosym/Insight II CAR format', 'bgf': 'MSI BGF format', 'box': 'Dock 3.5 Box format', 'bs': 'Ball and Stick format', 'c3d1': 'Chem3D Cartesian 1 format', 'c3d2': 'Chem3D Cartesian 2 format', 'caccrt': 'Cacao Cartesian format', 'car': 'Accelrys/MSI Biosym/Insight II CAR format', ...}<br>
<strong>outformats</strong> = {'alc': 'Alchemy format', 'bgf': 'MSI BGF format', 'box': 'Dock 3.5 Box format', 'bs': 'Ball and Stick format', 'c3d1': 'Chem3D Cartesian 1 format', 'c3d2': 'Chem3D Cartesian 2 format', 'cac': 'CAChe MolStruct format', 'caccrt': 'Cacao Cartesian format', 'cache': 'CAChe MolStruct format', 'cacint': 'Cacao Internal format', ...}</td></tr></table>
</body></html>