diff --git a/README.md b/README.md index 6b914a4aab3c2ca8068e5ec7bc0dbac38f0961c4..1099b912c5a5e072d631f4cf4338b298e09a8163 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,7 @@ Output: To install package, run ``` -pip install -r requirements.txt -pip install -r requirements_dev.txt +pip install . ``` diff --git a/setup.py b/setup.py index abcfdb7c1e60131eb9689d4de0f0c8a7eef80574..21a2fa248ad3c02d6614d7f5565fe823461a9103 100644 --- a/setup.py +++ b/setup.py @@ -18,5 +18,10 @@ setup( 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' + ] + } ) diff --git a/term_frag_sel/cli.py b/term_frag_sel/cli.py index 67b9f7d554b0f2376955a2c77338d2b726cce1e4..37188c9077b0cdfd4b5f016cb32d94ee49bc571d 100644 --- a/term_frag_sel/cli.py +++ b/term_frag_sel/cli.py @@ -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() diff --git a/term_frag_sel/fragmentation.py b/term_frag_sel/fragmentation.py index 9cd8a0ff760a81bc17cb6673ec80dcb932a0d290..f3471a0d96d5b80996639f1185bfde8abfe769ba 100644 --- a/term_frag_sel/fragmentation.py +++ b/term_frag_sel/fragmentation.py @@ -24,7 +24,7 @@ def fragmentation(fasta: dict, seq_counts: pd.DataFrame, term_frags = [] for seq_id, seq in fasta.items(): - counts = seq_counts[seq_counts["seqID"] == seq_id]["count"] + counts = seq_counts[seq_counts["seqID"] == str(seq_id)]["count"] for _ in range(counts.iloc[0]): cuts = [] seq_len = len(seq)