Skip to content
Snippets Groups Projects
Commit d0fc0ff5 authored by Amandine  PERRIN's avatar Amandine PERRIN
Browse files

Rename genomeAPCAT package to PanACoTA

parent 986cf683
No related branches found
No related tags found
No related merge requests found
File moved
File moved
File moved
File moved
#!/usr/bin/env python3
# coding: utf-8
import sys
from textwrap import dedent
from genomeAPCAT import __version__ as version
from genomeAPCAT.subcommands import annote
from genomeAPCAT.subcommands import pangenome
from genomeAPCAT.subcommands import corepers
from genomeAPCAT.subcommands import align
from genomeAPCAT.subcommands import tree
def main():
"""
Start program according to arguments given by user.
"""
action, args = parse_arguments(sys.argv[1:])
action(args)
def parse_arguments(argv):
"""
Extract command-line arguments for different actions.
"""
import argparse
# Create main parser
parser = argparse.ArgumentParser(
epilog="For more details, visit the MacSyFinder website and see "
"the MacSyFinder documentation.",
formatter_class=argparse.RawDescriptionHelpFormatter,
description=dedent('''
___ _____ ___ _____ _____
( _`\ ( _ )( _`\ (_ _)( _ )
| |_) ) _ _ ___ | (_) || ( (_) _ | | | (_) |
| ,__/'/'_` )/' _ `\| _ || | _ /'_`\ | | | _ |
| | ( (_| || ( ) || | | || (_( )( (_) )| | | | | |
(_) `\__,_)(_) (_)(_) (_)(____/'`\___/'(_) (_) (_)
Large scale comparative genomics tools
-------------------------------------------
''') )
parser.add_argument('-V', '--version', action='version',
version='genomeAPCAT - v. ' + str(version),
help="Print the version number and exit")
# Create subparsers, for all submodules
subparsers = parser.add_subparsers(dest='subparser_called')
# dest: to be able to get the subparser called with args.subparser_called
actions = {} # to add the action to do according to the subparser called
checks = {} # to add the function to call to check the subparser arguments
# QC and annotation part
parser_annote = subparsers.add_parser('annotate',
help="Quality control and annotation of genomes",
add_help=False)
annote.build_parser(parser_annote)
actions["annotate"] = annote.main_from_parse
checks["annotate"] = annote.check_args
# Pan genome part
parser_pan = subparsers.add_parser('pangenome', help="Generate a pan-genome of your dataset",
add_help=False)
pangenome.build_parser(parser_pan)
actions["pangenome"] = pangenome.main_from_parse
# Persistent genome part
parser_corepers = subparsers.add_parser('corepers',
help="Compute a Core or Persistent genome of your "
"dataset",
add_help=False)
corepers.build_parser(parser_corepers)
actions["corepers"] = corepers.main_from_parse
checks["corepers"] = corepers.check_args
# Alignment part
parser_align = subparsers.add_parser('align',
help="Align Core/Persistent familiest",
add_help=False)
align.build_parser(parser_align)
actions["align"] = align.main_from_parse
# tree part
parser_tree = subparsers.add_parser('tree',
help=("Infer phylogenetic tree based on "
"core/persistent genome"),
add_help=False)
tree.build_parser(parser_tree)
actions["tree"] = tree.main_from_parse
checks["tree"] = tree.check_args
# Parse arguments and execute corresponding action
arguments = parser.parse_args(argv)
arguments.argv = argv
action_called = arguments.subparser_called
# If checks are needed, do it (if some arguments are not compatible etc.)
if action_called in checks:
checks[action_called](parser, arguments)
# If subparser called does not exist, error
if action_called not in actions:
parser.error("too few arguments. Use '-h' to get help.")
return actions[action_called], arguments
if __name__ == '__main__':
main()
...@@ -46,11 +46,11 @@ def uninstall(): ...@@ -46,11 +46,11 @@ def uninstall():
Uninstall PanACoTA python package Uninstall PanACoTA python package
""" """
logger.info("Uninstalling PanACoTA...") logger.info("Uninstalling PanACoTA...")
cmd = "pip3 uninstall -y genomeAPCAT" cmd = "pip3 uninstall -y PanACoTA"
error = ("A problem occurred while trying to uninstall PanACoTA. If you have " error = ("A problem occurred while trying to uninstall PanACoTA. If you have "
"permission errors, try to add 'sudo' before your command line.") "permission errors, try to add 'sudo' before your command line.")
run_cmd(cmd, error) run_cmd(cmd, error)
link_dest = os.path.join(os.sep + "usr", "local", "bin", "genomeAPCAT") link_dest = os.path.join(os.sep + "usr", "local", "bin", "PanACoTA")
if os.path.exists(link_dest): if os.path.exists(link_dest):
os.remove(link_dest) os.remove(link_dest)
...@@ -99,7 +99,7 @@ def install_all(install_dir, target, dev=False, user=False): ...@@ -99,7 +99,7 @@ def install_all(install_dir, target, dev=False, user=False):
"you do not have root access, install with the '--user' option") "you do not have root access, install with the '--user' option")
run_cmd(cmd, error, eof=True) run_cmd(cmd, error, eof=True)
if user: if user:
gapcat_bin = os.path.join(os.getcwd(), "bin", "genomeAPCAT") gapcat_bin = os.path.join(os.getcwd(), "bin", "PanACoTA")
os.symlink(gapcat_bin, os.path.join(install_dir, os.path.basename(gapcat_bin))) os.symlink(gapcat_bin, os.path.join(install_dir, os.path.basename(gapcat_bin)))
if to_install_user: if to_install_user:
msg = ("Some dependencies needed for some subcommands of PanACoTA are not installed. " msg = ("Some dependencies needed for some subcommands of PanACoTA are not installed. "
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
Setup script Setup script
""" """
import genomeAPCAT import PanACoTA
try: try:
from setuptools import setup from setuptools import setup
from setuptools.command.test import test as TestCommand from setuptools.command.test import test as TestCommand
...@@ -38,16 +38,16 @@ def parse_requirements(requirements): ...@@ -38,16 +38,16 @@ def parse_requirements(requirements):
and not l.startswith('#')] and not l.startswith('#')]
packages = ['genomeAPCAT', 'genomeAPCAT.annote_module', packages = ['PanACoTA', 'PanACoTA.annote_module',
'genomeAPCAT.pangenome_module', 'genomeAPCAT.corepers_module', 'PanACoTA.pangenome_module', 'PanACoTA.corepers_module',
'genomeAPCAT.align_module', 'genomeAPCAT.tree_module', 'genomeAPCAT.subcommands'] 'PanACoTA.align_module', 'PanACoTA.tree_module', 'PanACoTA.subcommands']
requires = parse_requirements("requirements.txt") requires = parse_requirements("requirements.txt")
scripts = ['bin/genomeAPCAT'] scripts = ['bin/PanACoTA']
classifiers = [ classifiers = [
"Environment :: Console", "Environment :: Console",
"Intended Audience :: Science/Research", "Intended Audience :: Science/Research",
"License :: ???", "License :: AGPL v3",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Operating System :: OS Independent", "Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Bio-Informatics", "Topic :: Scientific/Engineering :: Bio-Informatics",
...@@ -57,9 +57,9 @@ with open('README.md') as f: ...@@ -57,9 +57,9 @@ with open('README.md') as f:
long_description = f.read() long_description = f.read()
setup( setup(
name='genomeAPCAT', name='PanACoTA',
packages=packages, packages=packages,
version=genomeAPCAT.__version__, version=PanACoTA.__version__,
description="Large scale comparative genomics tools: annotate genomes, do pangenome, " description="Large scale comparative genomics tools: annotate genomes, do pangenome, "
"core/persistent genome, align core/persistent families, infer phylogenetic tree.", "core/persistent genome, align core/persistent families, infer phylogenetic tree.",
long_description=long_description, long_description=long_description,
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment