Exemple #1
0
def cli():
    """Create command line interface and parse arguments for main program."""
    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument(
        "-i",
        "--fast5_dir",
        action=FullPathsList,
        help="""Directory of fast5 files you want to query. Program will
        walk recursively through subdirectories.""",
        type=str,
        nargs="+",
        required=True)

    parser.add_argument("-r",
                        "--reference",
                        action=FullPathsList,
                        help="""Fastq or BAM/SAM file(s).""",
                        nargs="+",
                        required=True)

    parser.add_argument(
        "-o",
        "--output",
        action=FullPaths,
        help="""Filename to write fast5 paths to. If nothing is entered,
        it will write the paths to STDOUT.""",
        default=None)

    parser.add_argument(
        "-m",
        "--mapped",
        action='store_true',
        help="Only extract read ids for mapped reads in BAM/SAM files.",
        default=False)

    parser.add_argument(
        "--log_level",
        help="Level of logging. 0 is none, 5 is for debugging. Default is 4 "
        "which will report info, warnings, errors, and critical "
        "information.",
        default=4,
        type=int,
        choices=range(6))

    parser.add_argument("--no_progress_bar",
                        help="Do not display progress bar.",
                        action='store_true',
                        default=False)

    args = parser.parse_args()
    setup_logging(args.log_level)
    if args.output is not None:
        args.output = open(args.output, 'w')
    logging.info(" Starting fast5seek.")
    fast5seek.main(args)
    logging.info(" Done.")
Exemple #2
0
    def test_EcoliTestFast5DataSam_TwoFilepaths(self):
        fast5_dir = ['tests/data/fast5']
        reference = ['tests/data/sam/ecoli.sam']
        args = TestArgs(fast5_dir, reference, True)

        f = io.StringIO()
        with redirect_stdout(f):
            fast5seek.main(args)
        stdout = f.getvalue()
        result = [x for x in stdout.split('\n') if x]
        expected = [
            'tests/data/fast5/ecoli1.fast5', 'tests/data/fast5/ecoli2.fast5'
        ]
        self.assertCountEqual(result, expected)
Exemple #3
0
    def test_TBTestFast5DataBam_SixFilepaths(self):
        fast5_dir = ['tests/data/fast5']
        reference = ['tests/data/bam/tb.bam']
        args = TestArgs(fast5_dir, reference, True)

        f = io.StringIO()
        with redirect_stdout(f):
            fast5seek.main(args)
        stdout = f.getvalue()
        result = [x for x in stdout.split('\n') if x]
        expected = [
            'tests/data/fast5/tb5.fast5', 'tests/data/fast5/tb6.fast5',
            'tests/data/fast5/tb4.fast5', 'tests/data/fast5/tb3.fast5',
            'tests/data/fast5/tb2.fast5', 'tests/data/fast5/tb1.fast5'
        ]
        self.assertCountEqual(result, expected)
Exemple #4
0
    def test_TBTestFast5DataAlbacoreFastq_EightFilepaths(self):
        fast5_dir = ['tests/data/fast5']
        reference = ['tests/data/fastq/basecalled.fastq.gz']
        args = TestArgs(fast5_dir, reference, False)

        f = io.StringIO()
        with redirect_stdout(f):
            fast5seek.main(args)
        stdout = f.getvalue()
        result = [x for x in stdout.split('\n') if x]
        expected = [
            'tests/data/fast5/ecoli1.fast5', 'tests/data/fast5/ecoli2.fast5',
            'tests/data/fast5/tb5.fast5', 'tests/data/fast5/tb6.fast5',
            'tests/data/fast5/tb4.fast5', 'tests/data/fast5/tb3.fast5',
            'tests/data/fast5/tb2.fast5', 'tests/data/fast5/tb1.fast5'
        ]
        self.assertCountEqual(result, expected)