-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(retropath2): add Preference object and add it to cmd line for knime
- Loading branch information
1 parent
eb7466f
commit 5b197ef
Showing
10 changed files
with
138 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import datetime | ||
import tempfile | ||
|
||
|
||
class Preference(object): | ||
def __init__(self, *args, **kwargs) -> None: | ||
self.path = kwargs.get("path", tempfile.NamedTemporaryFile(suffix=".epf").name) | ||
self.rdkit_timeout_minutes = kwargs.get("rdkit_timeout_minutes") | ||
|
||
def is_init(self) -> bool: | ||
if self.rdkit_timeout_minutes: | ||
return True | ||
return False | ||
|
||
def to_file(self) -> None: | ||
now = datetime.datetime.now(datetime.timezone.utc) | ||
with open(self.path, "w") as fod: | ||
fod.write("#") | ||
fod.write(now.strftime("%a %b %d %H:%M:%S %Z %Y")) | ||
fod.write("\n") | ||
fod.write("\\!/=") | ||
fod.write("\n") | ||
if self.rdkit_timeout_minutes: | ||
fod.write("/instance/org.rdkit.knime.nodes/mcsAggregation.timeout=") | ||
fod.write(str(int(self.rdkit_timeout_minutes) * 60)) | ||
fod.write("\n") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#Thu Nov 17 14:02:50 CET 2022 | ||
\!/= | ||
/instance/org.rdkit.knime.nodes/mcsAggregation.timeout=600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
Created on Jul 15 2020 | ||
@author: Joan Hérisson | ||
""" | ||
import os | ||
import tempfile | ||
|
||
from retropath2_wrapper.preference import Preference | ||
from tests.main_test import Main_test | ||
|
||
|
||
class TestPreference(Main_test): | ||
def test_init(self): | ||
pref = Preference(path=os.getcwd(), rdkit_timeout_minutes=50, rdkit="test") | ||
self.assertEqual(pref.path, os.getcwd()) | ||
self.assertEqual(pref.rdkit_timeout_minutes, 50) | ||
with self.assertRaises(Exception): | ||
pref.rdkit | ||
|
||
def test_to_file(self): | ||
pref = Preference(rdkit_timeout_minutes=10) | ||
pref.to_file() | ||
with open(pref.path) as fid: | ||
res = fid.read().splitlines() | ||
with open(self.preference) as fid: | ||
the = fid.read().splitlines() | ||
self.assertEqual(res[1:], the[1:]) | ||
|
||
def test_is_init(self): | ||
pref = Preference() | ||
self.assertFalse(pref.is_init()) | ||
pref = Preference(rdkit_timeout_minutes=10) | ||
self.assertTrue(pref.is_init()) | ||
|