Skip to content

Commit

Permalink
fragmentor distribution added.
Browse files Browse the repository at this point in the history
  • Loading branch information
stsouko committed Oct 15, 2019
1 parent a4104e0 commit 75c2e7c
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 15 deletions.
34 changes: 28 additions & 6 deletions CIMtools/preprocessing/fragmentor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#
from CGRtools.containers import MoleculeContainer, CGRContainer
from CGRtools.files import SDFWrite
from distutils.util import get_platform
from logging import info
from os import close
from os.path import devnull
Expand All @@ -35,21 +36,28 @@

class Fragmentor(BaseEstimator, TransformerMixin):
def __init__(self, fragment_type=3, min_length=2, max_length=10, cgr_dynbonds=0, doallways=False,
useformalcharge=False, header=None, workpath='.', version=None, verbose=False, remove_rare_ratio=0,
return_domain=False):
useformalcharge=False, header=None, workpath='.', version='2017',
verbose=False, remove_rare_ratio=0, return_domain=False):
"""
ISIDA Fragmentor wrapper
:param workpath: path for temp files.
:param version: fragmentor version. need for selecting Fragmentor executables named as fragmentor-{version}
:param fragment_type: fragmentation type. see Fragmentor manual (-t)
:param min_length: minimal length of fragments. see Fragmentor manual (-l)
:param max_length: maximal length of fragments. see Fragmentor manual (-u)
:param cgr_dynbonds: see Fragmentor manual (-d)
:param doallways: see Fragmentor manual (--DoAllWays)
:param useformalcharge: see Fragmentor manual (--UseFormalCharge)
:param header: if None descriptors will be generated on train set
if False Fragmentor will work in headless mode. in this mod fit unusable and Fragmentor return
all found descriptors
else path string to existing header file acceptable
:param workpath: path for temp files
:param version: fragmentor version
:param verbose: silent Fragmentor output
:param remove_rare_ratio: if descriptors found on train less then given ratio it will be removed from header.
if partial fit used, be sure to use finalize method.
unusable if headless mode set
:param return_domain: add AD bool column. if False molecule has new features
:param return_domain: add AD bool column. False in column is: molecule/CGR has new features
"""
self.fragment_type = fragment_type
self.min_length = min_length
Expand All @@ -73,6 +81,9 @@ def __getstate__(self):
k not in ('header', 'workpath') and not k.startswith('_Fragmentor__')}

def __setstate__(self, state):
if state['version'] is None:
state['version'] = '2017' # backward compatibility with <4.0

super().__setstate__({k: v for k, v in state.items() if k != '_Fragmentor__head_dump'})
# backward compatibility with 1.4.0 - 1.4.6
if '_Fragmentor__head_less' not in state:
Expand Down Expand Up @@ -303,7 +314,7 @@ def __parse_svm(svm_file, head_dict):
return DataFrame(vector, columns=list(head_dict.values())).fillna(0), Series(ad)

def __exec_params(self, inp, out):
tmp = [f'fragmentor-{self.version}' if self.version else 'fragmentor', '-i', str(inp), '-o', str(out)]
tmp = [fragmentor % self.version, '-i', str(inp), '-o', str(out)]

if self.__head_exec:
tmp.extend(('-h', str(self.__head_exec)))
Expand Down Expand Up @@ -369,3 +380,14 @@ def __init_header(self):


__all__ = ['Fragmentor']

platform = get_platform()
if platform == 'win-amd64':
fragmentor = 'fragmentor_win_%s.exe'
elif platform == 'linux-x86_64':
fragmentor = 'fragmentor_lin_%s'
# elif platform.startswith('macosx') and platform.endswith('x86_64'):
# fragmentor = 'fragmentor_mac_%s'
else:
del Fragmentor
__all__ = []
5 changes: 5 additions & 0 deletions Fragmentor/LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This program (ISIDA Fragmentor2017) is distributed as is
in the hope that it will be useful, but WITHOUT ANY WARRANTY.

(c) G. Marcou, D. Horvath, A. Varnek F. Ruggiu, V. Solov'ev, E. Moyemont
Universite de Strasbourg Faculte de Chimie Laboratoire d'infochimie
Binary file added Fragmentor/doc/Fragmentor2015_MDL_SDF.pdf
Binary file not shown.
Binary file added Fragmentor/doc/Fragmentor2015_Nomenclature.pdf
Binary file not shown.
Binary file added Fragmentor/doc/Fragmentor2017_Manual.pdf
Binary file not shown.
Binary file added Fragmentor/fragmentor_lin_2017
Binary file not shown.
Binary file added Fragmentor/fragmentor_win_2017.exe
Binary file not shown.
16 changes: 16 additions & 0 deletions Fragmentor/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*********************************************

ISIDA Fragmentor2017
This is a terminal interface for
generating molecular fragments

G. Marcou, D. Horvath, A. Varnek
F. Ruggiu, V. Solov'ev, E. Moyemont

2017

Universite de Strasbourg
Faculte de Chimie
Laboratoire d'infochimie

*********************************************
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ or latest repository version
* add CHEMAXON_REST (optional)

export CHEMAXON_REST="url/to/webservices"

* edit PATH for Fragmentor using. Add path to fragmentor bin files
38 changes: 31 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,58 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <https://www.gnu.org/licenses/>.
#
from distutils.util import get_platform
from pathlib import Path
from setuptools import setup, find_packages
from wheel.bdist_wheel import bdist_wheel


version = '4.0.0'

platform = get_platform()
if platform == 'win-amd64':
fragmentor = ['Fragmentor/fragmentor_win_2017.exe']
elif platform == 'linux-x86_64':
fragmentor = ['Fragmentor/fragmentor_lin_2017']
# elif platform.startswith('macosx') and platform.endswith('x86_64'):
# fragmentor = ['Fragmentor/fragmentor_mac_2017']
else:
fragmentor = []


class _bdist_wheel(bdist_wheel):
def finalize_options(self):
super().finalize_options()
self.root_is_pure = False


setup(
name='CIMtools',
version=version,
packages=find_packages(),
zip_safe=True,
url='https://github.com/stsouko/CIMtools',
license='GPLv3',
author='Dr. Ramil Nugmanov',
author_email='stsouko@live.ru',
python_requires='>=3.6.1',
install_requires=['CGRtools>=4.0,<4.1', 'pandas>=0.22.0,<0.26', 'scikit-learn>=0.20.1,<0.22',
cmdclass={'bdist_wheel': _bdist_wheel},
install_requires=['CGRtools[mrv]>=4.0,<4.1', 'pandas>=0.22.0,<0.26', 'scikit-learn>=0.20.1,<0.22',
'requests>=2.21,<2.23', 'pyparsing>=2.2.0,<2.5', 'numpy>=1.15.0,<1.18'],
data_files=[('bin', fragmentor)],
zip_safe=False,
long_description=(Path(__file__).parent / 'README.md').open().read(),
classifiers=['Environment :: Plugins',
'Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'Topic :: Scientific/Engineering :: Chemistry',
'Topic :: Software Development :: Libraries :: Python Modules',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7']
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Chemistry',
'Topic :: Scientific/Engineering :: Information Analysis',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules']
)

0 comments on commit 75c2e7c

Please sign in to comment.