# Path: conkit/plot/tools.py
# def is_executable(executable):
#     """Check if a given program can be executed
# 
#     Parameters
#     ----------
#     executable : str
#        The path or name for an executable
# 
#     Returns
#     -------
#     str
#        The absolute path to the executable
# 
#     Raises
#     ------
#     ValueError
#         The executable cannot be accessed
# 
#     Credits
#     -------
#     https://stackoverflow.com/a/377028/3046533
#     """
#     if executable is None:
#         return
# 
#     fpath, fname = os.path.split(executable)
# 
#     if fpath:
#         if os.path.isfile(executable) and os.access(executable, os.X_OK):
#             return executable
# 
#     else:
#         for path in os.environ["PATH"].split(os.pathsep):
#             exe_file = os.path.join(path, executable)
#             if os.path.isfile(exe_file) and os.access(exe_file, os.X_OK):
#                 return exe_file
# 
#     raise ValueError('Executable {} cannot be accessed'.format(executable))


import argparse
import os
import conkit.applications
import conkit.command_line
import conkit.io
import conkit.plot
    import sys
    import traceback
from Bio.PDB import PDBParser
from Bio.PDB.DSSP import DSSP
from prettytable import PrettyTable
from conkit.plot.tools import is_executable

It uses one external program to perform this task:

   map_align for contact map alignment

*** This program needs to be installed separately from https://github.com/sokrypton/map_align***

"""



logger = None


def create_argument_parser():
    """Create a parser for the command line arguments used in conkit-validate"""

    parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument("seqfile", type=check_file_exists, help="Path to sequence file")
    parser.add_argument("seqformat", type=str, help="Sequence format")
    parser.add_argument("distfile", type=check_file_exists, help="Path to distance prediction file")
    parser.add_argument("distformat", type=str, help="Format of distance prediction file",
                        choices=list(conkit.io.DISTANCE_FILE_PARSERS.keys()))
    parser.add_argument("pdbfile", type=check_file_exists, help="Path to structure file")
    parser.add_argument("pdbformat", type=str, help="Format of structure file", choices=['pdb', 'mmcif'])
    parser.add_argument("-dssp_exe", dest="dssp", default='mkdssp', help="path to dssp executable", type=is_executable)
    parser.add_argument("-output", dest="output", default="conkit.png", help="path to output figure png file", type=str)
    parser.add_argument("--overwrite", dest="overwrite", default=False, action="store_true",
                        help="overwrite output figure png file if it already exists")
    parser.add_argument("--map_align_exe", dest="map_align_exe", default=None,

# Path: conkit/plot/tools.py
# def is_executable(executable):
#     """Check if a given program can be executed
# 
#     Parameters
#     ----------
#     executable : str
#        The path or name for an executable
# 
#     Returns
#     -------
#     str
#        The absolute path to the executable
# 
#     Raises
#     ------
#     ValueError
#         The executable cannot be accessed
# 
#     Credits
#     -------
#     https://stackoverflow.com/a/377028/3046533
#     """
#     if executable is None:
#         return
# 
#     fpath, fname = os.path.split(executable)
# 
#     if fpath:
#         if os.path.isfile(executable) and os.access(executable, os.X_OK):
#             return executable
# 
#     else:
#         for path in os.environ["PATH"].split(os.pathsep):
#             exe_file = os.path.join(path, executable)
#             if os.path.isfile(exe_file) and os.access(exe_file, os.X_OK):
#                 return exe_file
# 
#     raise ValueError('Executable {} cannot be accessed'.format(executable))


# Path: conkit/command_line/conkit_validate.py
import argparse
import os
import conkit.applications
import conkit.command_line
import conkit.io
import conkit.plot
    import sys
    import traceback
from Bio.PDB import PDBParser
from Bio.PDB.DSSP import DSSP
from prettytable import PrettyTable
from conkit.plot.tools import is_executable


It uses one external program to perform this task:

   map_align for contact map alignment

*** This program needs to be installed separately from https://github.com/sokrypton/map_align***

"""



logger = None


def create_argument_parser():
    """Create a parser for the command line arguments used in conkit-validate"""

    parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument("seqfile", type=check_file_exists, help="Path to sequence file")
    parser.add_argument("seqformat", type=str, help="Sequence format")
    parser.add_argument("distfile", type=check_file_exists, help="Path to distance prediction file")
    parser.add_argument("distformat", type=str, help="Format of distance prediction file",
                        choices=list(conkit.io.DISTANCE_FILE_PARSERS.keys()))
    parser.add_argument("pdbfile", type=check_file_exists, help="Path to structure file")
    parser.add_argument("pdbformat", type=str, help="Format of structure file", choices=['pdb', 'mmcif'])
    parser.add_argument("-dssp_exe", dest="dssp", default='mkdssp', help="path to dssp executable", type=is_executable)
    parser.add_argument("-output", dest="output", default="conkit.png", help="path to output figure png file", type=str)
    parser.add_argument("--overwrite", dest="overwrite", default=False, action="store_true",
                        help="overwrite output figure png file if it already exists")
    parser.add_argument("--map_align_exe", dest="map_align_exe", default=None,

                        type=is_executable, help="Path to the map_align executable")