From 1efe9b84296d8d1659f7169187dfb5436a9b838c Mon Sep 17 00:00:00 2001 From: garion0000 <michele.garioni@unibas.ch> Date: Wed, 8 Dec 2021 11:25:05 +0100 Subject: [PATCH] fix: add cli --- src/{sampleinput.py => sample_from_input.py} | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) rename src/{sampleinput.py => sample_from_input.py} (69%) diff --git a/src/sampleinput.py b/src/sample_from_input.py similarity index 69% rename from src/sampleinput.py rename to src/sample_from_input.py index a6cc7e7..817d96b 100644 --- a/src/sampleinput.py +++ b/src/sample_from_input.py @@ -71,3 +71,30 @@ def sample_from_input( myfile.write(line + '\n') myfile.close() LOG.info('output written.') + + +def main(): + """CLI interface for the transcripts sampler. + + Accepts arguments from the command line and + runs the transcript sampler. + """ + import argparse + parser = argparse.ArgumentParser(description='Read functions argument') + parser.add_argument('input', action='store', + type=Path, help='path of the input file') + parser.add_argument('-o', action='store', + type=Path, default=Path.cwd() / 'sampled_cell.csv', + help='path of the output file') + parser.add_argument('-n', action='store', + type=int, default=10000, + help='number of total reads to be simulated') + parser.add_argument('-sep', action='store', + type=str, default=',', + help='separator of the input file') + args = parser.parse_args() + sample_from_input(args.input, args.o, args.n, args.sep) + + +if __name__ == '__main__': + main() -- GitLab