# CONFIDENTIAL. (C) 2017 OpenEye Scientific Software Inc.
# All rights reserved.
#
# ALL SOFTWARE BELOW IS PROPRIETARY AND CONFIDENTIAL TO OPENEYE
# SCIENTIFIC SOFTWARE INC., AND IS SUBJECT TO THE FULL PROTECTION OF
# COPYRIGHT AND TRADESECRET LAW.
# Copying or modifying this software is strictly prohibited and illegal.
# Using this software without a valid license from OpenEye is strictly
# prohibited and illegal. De-obfuscating, de-minimizing, or any other
# attempt to reverse engineer or discover the workings of this software,
# is strictly prohibited. Even if software is exposed or visible, it is
# still proprietary and confidential and the above prohibitions apply.
# This software is NOT "Sample Code". For purposes of customization or
# interoperation with other software you must use Sample Code
# specifically labeled as such.
# Please contact OpenEye at eyesopen.com/legal if you have any questions
# about this warning.
"""
 Test suite for OEDocking TK examples
"""

import pytest
from . import OETestCase, check_license


@pytest.mark.skipif(check_license('docking') is False, reason='OEDocking license not found')
class TestDocking(OETestCase):

    def test_rescore_poses(self):
        script = self.run_example(
            '{0}/docking/RescorePoses.py'.format(self.EXAMPLES_DIR),
            '-receptor', '{0}/receptor.oedu'.format(self.DATA_DIR),
            '-in', '{0}/conformers.oeb.gz'.format(self.DATA_DIR),
            '-out', 'rescoreposes.oeb.gz')
        self.assertFalse(script.returncode)

    def test_pose_molecules(self):
        script = self.run_example(
            '{0}/docking/PoseMolecules.py'.format(self.EXAMPLES_DIR),
            '-receptor', '{0}/receptor.oedu'.format(self.DATA_DIR),
            '-in', '{0}/1di9.sdf'.format(self.DATA_DIR),
            '-out', 'posemolecules.oedu')
        self.assertFalse(script.returncode)

    def test_dock_score_tagging(self):
        script = self.run_example(
            '{0}/docking/DockScoreTagging.py'.format(self.DOCEXAMPLES_DIR),
            '{0}/receptor.oeb.gz'.format(self.DATA_DIR),
            '{0}/conformers.oeb.gz'.format(self.DATA_DIR))
        self.assertFalse(script.returncode)

    def test_receptor_bound_ligand_editing(self):
        script = self.run_example(
            '{0}/docking/RecBoundLigandEdit.py'.format(self.DOCEXAMPLES_DIR),
            '{0}/receptor.oeb.gz'.format(self.DATA_DIR))
        self.assertFalse(script.returncode)

    def test_pose_molecules_with_multi_receptor(self):
        script = self.run_example(
            '{0}/docking/PoseMolsMultiReceptor.py'.format(self.EXAMPLES_DIR),
            '-receptors', '{0}/receptor.oedu'.format(self.DATA_DIR),
            '-in', '{0}/conformers.oeb.gz'.format(self.DATA_DIR),
            '-out', 'PoseMolsMultiReceptor.oedu', expect_stderr=True)
        self.assertFalse(script.returncode)
