Beispiel #1
0
def _check_input_bam_valid(args, log=None): #pylint: disable=unused-argument
    try:
        bamfile = samtools.alignment_file(args.input_bam, 'rb')
        bamfile.close()
    except ValueError:
        raise utils.UsageError(("Specified input [{}] not a valid BAM. Review "
                                "inputs and try again.").format(args.input_bam))
Beispiel #2
0
def _check_input_bam_indexed(args, log=None): #pylint: disable=unused-argument
    bamfile = samtools.alignment_file(args.input_bam, 'rb')
    try:
        bamfile.fetch()
    except ValueError:
        raise utils.UsageError(("Specified input [{}] is not indexed. Review "
                                "inputs and try again.").format(args.input_bam))
    finally:
        bamfile.close()
Beispiel #3
0
def _check_input_bam_not_empty(args, log=None): #pylint: disable=unused-argument
    bamfile = samtools.alignment_file(args.input_bam, 'rb')
    try:
        next(bamfile.fetch())
    except StopIteration:
        msg = "Specified input [{}] is empty"
        raise utils.UsageError(msg.format(args.input_bam))
    finally:
        bamfile.close()
Beispiel #4
0
 def error(self, message):
     '''Suppress default exit behavior'''
     raise utils.UsageError(message)
Beispiel #5
0
def _check_input_bam_exists(args, log=None): #pylint: disable=unused-argument
    if not os.path.exists(args.input_bam):
        raise utils.UsageError(("Specified input [{}] does not exist. Review "
                                "inputs and try again.").format(args.input_bam))
Beispiel #6
0
def _log_force_or_raise(args, log, msg):
    if args.force:
        log.warning(msg + ' (**forcing**)')
    else:
        raise utils.UsageError(msg + ' Are you sure? (--force to proceed)')