-
Notifications
You must be signed in to change notification settings - Fork 119
/
Copy pathencode_task_bam_to_pbam.py
executable file
·64 lines (50 loc) · 1.67 KB
/
encode_task_bam_to_pbam.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
# Author: Jin Lee ([email protected])
import sys
import os
import argparse
from encode_lib_common import (
log,
ls_l,
mkdir_p,
rm_f,
)
from encode_lib_genomic import (
bam_to_pbam,
)
def parse_arguments():
parser = argparse.ArgumentParser(prog='ENCODE bam to pbam',
description='')
parser.add_argument('bam', type=str,
help='Path for BAM.')
parser.add_argument('--ref-fa', type=str,
help='Path for reference fasta.')
parser.add_argument('--delete-original-bam', action='store_true',
help='Delete original BAM after conversion.')
parser.add_argument('--out-dir', default='', type=str,
help='Output directory.')
parser.add_argument('--log-level', default='INFO',
choices=['NOTSET', 'DEBUG', 'INFO',
'WARNING', 'CRITICAL', 'ERROR',
'CRITICAL'],
help='Log level')
args = parser.parse_args()
log.setLevel(args.log_level)
log.info(sys.argv)
return args
def main():
# read params
args = parse_arguments()
log.info('Initializing and making output directory...')
mkdir_p(args.out_dir)
# generate read length file
log.info('Converting BAM into pBAM...')
bam_to_pbam(args.bam, args.ref_fa, args.out_dir)
if args.delete_original_bam:
log.info('Deleting original BAM...')
rm_f(args.bam)
log.info('List all files in output directory...')
ls_l(args.out_dir)
log.info('All done.')
if __name__ == '__main__':
main()