Exemple #1
0
def _clean_reads(kromsatel_args):

    result_status = 1

    try:
        if kromsatel_args.kromsatel_mode == KromsatelModes.IlluminaPE:
            runner = core.IlluminaPEKromsatelCore(kromsatel_args)
        elif kromsatel_args.kromsatel_mode == KromsatelModes.Nanopore:
            runner = core.LongReadKromsatelCore(kromsatel_args)
        elif kromsatel_args.kromsatel_mode == KromsatelModes.IlluminaSE:
            runner = core.IlluminaSEKromsatelCore(kromsatel_args)
        # end if
        runner.run()

    except InvalidFastqError as err:
        print_err(err.msg_to_print)
        msg_to_log = '{}\n{}\n'.format(
            err.msg_to_print,
            err.msg_to_log_only
        )
        fs.log_to_file(msg_to_log, kromsatel_args.outdir_path)

    except FatalError as err:
        print_err(str(err))

    else:
        result_status = 0
    # end try

    return result_status
Exemple #2
0
def main():

    args = _parse_arguments()

    _check_blastplus_dependencies(args)

    print(str(args), end='\n\n')

    db_fpath = _create_database(args)
    args.set_database_path(db_fpath)

    print('{} - Start.'.format(getwt()))

    result_status = _clean_reads(args)

    _cleanup(args)

    if result_status == 0:
        print('\n{} - Completed.'.format(getwt()))
        print('  Output directory: `{}`'.format(args.outdir_path))
    else:
        print_err('\n\a{} - Completed with errors.'.format(getwt()))
    # end if

    return result_status
Exemple #3
0
def _parse_arguments():
    try:
        args = src.parse_args.parse_args()
    except FatalError as err:
        print_err(str(err))
        platformwise_exit(1)
    # end try
    return args
Exemple #4
0
def _create_database(kromsatel_args):
    try:
        db_fpath = src.blast.create_reference_database(kromsatel_args)
    except FatalError as err:
        print_err(str(err))
        platformwise_exit(1)
    # end try

    return db_fpath
Exemple #5
0
def _check_blastplus_dependencies(kromsatel_args):
    blastplus_dependencies = src.blast.get_blastplus_dependencies(kromsatel_args)

    try:
        for ncbi_program in blastplus_dependencies:
            src.blast.check_program(ncbi_program)
        # end for
    except FatalError as err:
        print_err(str(err))
        platformwise_exit(1)
Exemple #6
0
def log_to_file(message, outdir_path):
    log_fpath = os.path.join(
        outdir_path, 'error_log.log'
    )
    print_err('Logging to file `{}`'.format(log_fpath))

    with open(log_fpath, 'wt') as log_file:
        log_file.write('kromsatel start time: {}\n' \
            .format(strftime('%Y-%m-%d %H:%M:%S', gmtime(START_TIME)))
        )
        log_file.write(message)
Exemple #7
0
 def _create_tmp_directory(self):
     self.tmp_dir_path = os.path.join(
         self.outdir_path, 'tmp'
     )
     try:
         fs.create_dir(self.tmp_dir_path)
     except FatalError as err:
         print_err('\nError: cannot create temporary directory `{}`' \
             .format(self.tmp_dir_path))
         print_err(err)
         print_err('The program will use the root of the output directory' \
             ' as a storage of temporary files')
         self.tmp_dir_path = self.outdir_path
Exemple #8
0
def try_rm_directory(dirpath):
    try:
        shutil.rmtree(dirpath)
    except OSError as err:
        print_err('\nWarning: cannot remove temporary directory `{}`'.format(dirpath))
        print_err(str(err))
Exemple #9
0
def rm_file_warn_on_error(file_path):
    try:
        os.unlink(file_path)
    except OSError as oserr:
        print_err('\nWarning: Cannot remove file `{}`'.format(file_path))
        print_err( str(oserr) )