예제 #1
0
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

import unittest
import gzip
import re

from mmpdblib import commandline

from support import capture_stdout, capture_stderr
from support import get_filename, create_test_filename

from rdkit import Chem
wildcard_atom = Chem.CanonSmiles("*")
if wildcard_atom == "[*]":
    TEST_DATA_MMPDB = get_filename("test_data.mmpdb")
elif wildcard_atom == "*":
    # The dataset was generated with:
    #   python -m mmpdblib.commandline index test_data.fragments --properties test_data.csv -o test_data_2018.mmpdb
    TEST_DATA_MMPDB = get_filename("test_data_2018.mmpdb")
else:
    raise AssertionError(wildcard_atom)


class Table(list):
    def get_column(self, column_name):
        i = self[0].index(column_name)
        return [row[i] for row in self[1:]]


def parse_table(output):
예제 #2
0
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

import unittest
import json

from mmpdblib import commandline
from mmpdblib import dbutils

from support import get_filename, create_test_filename

TEST_DATA_FRAGMENTS = get_filename("test_data.fragments")
TEST_DATA_CSV = get_filename("test_data.csv")


def index(mmpdb_filename, *args):
    args = ("--quiet", "index", TEST_DATA_FRAGMENTS, "-o",
            mmpdb_filename) + tuple(args)
    try:
        commandline.main(args)
    except SystemExit as err:
        raise AssertionError("SystemExit trying to run %r: %s" % (args, err))


class TestIndexCommandline(unittest.TestCase):
    def _get_options(self, *args):
        mmpdb_filename = create_test_filename(self, "default.mmpdb")
예제 #3
0
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

import unittest
import gzip

import mmpdblib
from mmpdblib import commandline
from mmpdblib import fragment_io
from mmpdblib.config import DEFAULT_FRAGMENT_OPTIONS

from support import (redirect_stdin, capture_stdout, capture_stderr,
                     get_filename, create_testdir_and_filename, StringIO)

TAB_SMI = get_filename("tab.smi")
TWO_TABS_SMI = get_filename("two_tabs.smi")
SPACE_SMI = get_filename("space.smi")
SPACE_SMI_GZ = get_filename("space.smi.gz")
COMMA_SMI = get_filename("comma.smi")
CACHED_FRAGMENTS = get_filename("cached.fragments")

from rdkit import Chem
wildcard_atom = Chem.CanonSmiles("*")
if wildcard_atom == "[*]":
    # The tests were made for the pre-2018 when RDKit returned "[*]"
    def FIX(s):
        return s
elif wildcard_atom == "*":
    # RDKit 2018 change the behavior to return "*"
    def FIX(s):