Skip to content
Snippets Groups Projects
Commit acd2a084 authored by Mate Balajti's avatar Mate Balajti
Browse files

refactor: update CLI

parent c6b96e6b
No related branches found
No related tags found
1 merge request!58refactor: update CLI
Pipeline #17249 passed
......@@ -29,8 +29,7 @@ Output:
To install package, run
```
pip install -r requirements.txt
pip install -r requirements_dev.txt
pip install .
```
......
"""Set up project."""
from setuptools import setup, find_packages
from pathlib import Path
from setuptools import setup, find_packages
project_root_dir = Path(__file__).parent.resolve()
with open(project_root_dir / "requirements.txt",
"r", encoding="utf-8") as f:
INSTALL_REQUIRES = f.read().splitlines()
url = 'https://git.scicore.unibas.ch/zavolan_group/tools/terminal-fragment-selector'
URL = ('https://git.scicore.unibas.ch/zavolan_group/'
'tools/terminal-fragment-selector')
setup(
name='terminal-fragment-selector',
version='0.1.1',
url=url,
url=URL,
license='MIT',
author='Hugo Madge Leon, Sunho Kim, Tanya Nandan',
author_email='hmadge@ethz.ch',
description='Terminal fragment selector',
packages=find_packages(),
install_requires=INSTALL_REQUIRES
install_requires=INSTALL_REQUIRES,
entry_points={
'console_scripts': [
'terminal-fragment-selector=term_frag_sel.cli:main'
]
}
)
......@@ -18,13 +18,15 @@ logging.basicConfig(
logger = logging.getLogger("main")
def main(args: argparse.Namespace):
def main():
"""Use CLI arguments to fragment sequences and output text file \
with selected terminal fragments.
Args:
args (parser): list of arguments from CLI.
"""
args = parse_arguments()
if not isinstance(args, argparse.Namespace):
raise TypeError("Input should be argparse.Namespace")
......@@ -38,8 +40,10 @@ def main(args: argparse.Namespace):
logger.info("Fragmentation of %s...", args.fasta)
splits = np.arange(0, len(list(fasta))+args.size, args.size)
for i, split in enumerate(splits):
fasta_dict = fasta[split:splits[i+1]]
for i in range(len(splits) - 1):
split = splits[i]
keys = list(fasta.keys())[split:splits[i+1]]
fasta_dict = {key: fasta[key] for key in keys}
term_frags = fragmentation(fasta_dict, seq_counts,
args.mean, args.std)
......@@ -132,6 +136,4 @@ if __name__ == '__main__':
level=logging.INFO,
)
logger = logging.getLogger(__name__)
arguments = parse_arguments()
main(arguments)
main()
......@@ -23,5 +23,4 @@ def check_positive(value: str) -> int:
except ValueError as exc:
raise argparse.ArgumentTypeError(f"""Expected positive integer,
got: {value}""") from exc
else:
return ivalue
return ivalue
......@@ -27,5 +27,5 @@ def test_file():
def test_main():
"""Test main() function."""
with pytest.raises(TypeError):
main("")
with pytest.raises(SystemExit):
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment