Skip to content

Commit

Permalink
setup refactored.
Browse files Browse the repository at this point in the history
modelbuilder launcher moved to setup.py
dragos launchers fixed. now use configs.
config.py refactored

readme upd
  • Loading branch information
Ramil Nugmanov committed Apr 13, 2017
1 parent 9ecc16a commit 7948a1d
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 51 deletions.
17 changes: 9 additions & 8 deletions MODtools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@
from os.path import join, exists, dirname, expanduser

CHEMAXON = "https://cimm.kpfu.ru/webservices"
JCHEMBIN = '/opt/JChem/bin'
FRAGMENTOR = '/opt/fragmentor/fragmentor'
EED = '/opt/dragos/eedstart.sh'
COLOR = '/opt/dragos/colorstart.sh'
GACONF = '/opt/dragos/gaconfstarter.sh'
JCHEMBIN = join(expanduser('~'), 'ChemAxon/JChem/bin')
FRAGMENTOR = join(expanduser('~'), 'fragmentor/fragmentor')

config_list = ('CHEMAXON', 'JCHEMBIN', 'FRAGMENTOR', 'EED', 'COLOR', 'GACONF')
EED = 'eedstart.sh'
COLOR = 'colorstart.sh'
GACONF = 'gaconfstarter.sh'

config_dirs = [join(x, '.MODtools.ini') for x in (expanduser('~'), '/etc', dirname(__file__))]
config_list = ('CHEMAXON', 'JCHEMBIN', 'FRAGMENTOR')

config_dirs = [join(x, '.MODtools.ini') for x in (dirname(__file__), expanduser('~'), '/etc')]

if not any(exists(x) for x in config_dirs):
with open(config_dirs[0], 'w') as f:
with open(config_dirs[1], 'w') as f:
f.write('\n'.join('%s = %s' % (x, y or '') for x, y in globals().items() if x in config_list))

with open(next(x for x in config_dirs if exists(x))) as f:
Expand Down
9 changes: 8 additions & 1 deletion MODtools/modelbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from .descriptors.eed import Eed
from .descriptors.fragmentor import Fragmentor
from .estimators.svmodel import SVModel
from .parsers import MBparser
from .parsers import MBparser, argparser


def desc_starter(func, file_dump, out_file, fformat, header, is_reaction):
Expand Down Expand Up @@ -326,3 +326,10 @@ def __dragos_svm_fit(self, input_file, _type):
svm.append({'scale' if y == 'scaled' else 'orig': list(x.values())[0]})
return svm, cleared
raise Exception('GAConf failed')


def launcher():
args = argparser()
input_file = args.pop('input')
main = ModelBuilder(args)
main.run(input_file)
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
MODTools
=========
classes for models preparation

usage
=====
modeler -h


INSTALL
=====

*step 1:*

pip install -U git+https://github.com/stsouko/MODtools.git@master#egg=MODtools --process-dependency-links --allow-all-external

*step 2:*

type

modeler -h

*step 3:*

add or edit ~/.MODtools.rc or /etc/.MODtools.rc file. local *.rc has higher priority.

GACONF=~/GAconfig
UTILS_DIR=~
CHMXN_DIR=~/ChemAxon

replace default paths to actual.
* GACONF - Dragos's Genetic SVM optimizer
* CHMXN_DIR - dir with JChem distributive
* UTILS_DIR - dir with Dragos's utilities

edit `~/.MODtools.ini` or add `/etc/.MODtools.ini`
or add file into package `MODtools/.MODtools.ini` [useful for unpacked MODtools Lib]

priority: `MODtools/.MODtools.ini` >> `~/.MODtools.ini` >> `/etc/.MODtools.ini`
15 changes: 12 additions & 3 deletions SETUP/colorstart.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#!/usr/bin/env bash

UTILS_DIR=/home/stsouko
CHMXN_DIR=/home/stsouko/ChemAxon
UTILS_DIR=~
CHMXN_DIR=~/ChemAxon

if [ -f /etc/.MODtools.rc ]; then
. /etc/.MODtools.rc
fi

if [ -f ~/.MODtools.rc ]; then
. ~/.MODtools.rc
fi

export SETUP_DIR=${UTILS_DIR}/Utils
export FORCEFIELD=${SETUP_DIR}/cvffTemplates.xml
export CLASSPATH=${CHMXN_DIR}/JChem/lib/jchem.jar:${UTILS_DIR}:

java Utils/CA_Prop_Map2011 -f $1 -o $2 -stdoptions $3
java Utils/CA_Prop_Map2011 -f $1 -o $2 -stdoptions $3
16 changes: 15 additions & 1 deletion SETUP/dragosgfstarter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,21 @@
# $4 repetitions
# $5 CV
# $workdir /path/to/worktmp.file{/}
GACONF=/path/to/ga

GACONF_PATH=~/GAconfig
LIBSVM_PATH=${GACONF_PATH}/libsvm-3.20

if [ -f /etc/.MODtools.rc ]; then
. /etc/.MODtools.rc
fi

if [ -f ~/.MODtools.rc ]; then
. ~/.MODtools.rc
fi

export LIBSVM=${SVMLIB_PATH}
export GACONF=${GACONF_PATH}
export LC_ALL=en_US.UTF-8

datadir=$1
workdir=${datadir}/work
Expand Down
12 changes: 10 additions & 2 deletions SETUP/eedstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

[ $# -ge 1 -a -f "$1" ] && input="$1" || input="-"

UTILS_DIR=/home/stsouko
CHMXN_DIR=/home/stsouko/ChemAxon
UTILS_DIR=~
CHMXN_DIR=~/ChemAxon

if [ -f /etc/.MODtools.rc ]; then
. /etc/.MODtools.rc
fi

if [ -f ~/.MODtools.rc ]; then
. ~/.MODtools.rc
fi

export CLASSPATH=${CHMXN_DIR}/JChem/lib/jchem.jar:${UTILS_DIR}:

Expand Down
30 changes: 0 additions & 30 deletions modelbuilder.py

This file was deleted.

8 changes: 8 additions & 0 deletions requirenments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
typing
pandas
scipy
dill
sortedcontainers
sklearn
requests
git+https://github.com/stsouko/CGRtools.git@master#egg=CGRtools
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[easy_install]
allow_hosts = github.com, pypi.python.org
11 changes: 5 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,17 @@
setup(
name='modtools',
version=version(),
packages=find_packages(exclude=[]),
packages=find_packages(),
url='https://github.com/stsouko/MODtools',
license='AGPLv3',
author='Dr. Ramil Nugmanov',
author_email='stsouko@live.ru',
description='Modeler tools',
scripts=['modelbuilder.py'],
entry_points={'console_scripts': ['modeler=MODtools.modelbuilder:launcher']},
scripts=['SETUP/colorstart.sh', 'SETUP/dragosgfstarter.sh', 'SETUP/eedstart.sh'],
package_data={'': ['unwanted.elem', 'standardrules_dragos.rules']},
requires=['networkx', 'typing', 'periodictable', 'numpy', 'pandas', 'dill', 'sortedcontainers', 'sklearn',
'requests', 'CGRtools'],
dependency_links=['https://github.com/stsouko/CGRtools.git@master#egg=CGRtools',
'https://github.com/networkx/networkx.git@master#egg=networkx'],
install_requires=['typing', 'pandas', 'scipy', 'dill', 'sortedcontainers', 'sklearn', 'requests', 'CGRtools'],
dependency_links=['git+https://github.com/stsouko/CGRtools.git@master#egg=CGRtools-2.6'],
long_description='Modeler tools distributive. include ISIDA Fragmentor and EED python wrappers',

keywords="tools modeler cli ISIDA Framentor EED SVM IAP",
Expand Down

0 comments on commit 7948a1d

Please sign in to comment.