-
Notifications
You must be signed in to change notification settings - Fork 4
/
convert.py
64 lines (50 loc) · 1.79 KB
/
convert.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
"""
XPRESSpipe
An alignment and analysis pipeline for RNAseq data
alias: xpresspipe
Copyright (C) 2019 Jordan A. Berg
jordan <dot> berg <at> biochem <dot> utah <dot> edu
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>.
"""
from __future__ import print_function
"""IMPORT DEPENDENCIES"""
import os
import sys
"""IMPORT INTERNAL DEPENDENCIES"""
from .utils import get_files, add_directory
from .parallel import parallelize
"""Convert sorted sam files in directory to bed files"""
def bed_convert(
args):
file, args_dict = args[0], args[1] # Parse args
# Convert BAM to BED
os.system(
'bedtools bamtobed'
+ ' -i ' + str(args_dict['input']) + str(file).rsplit('.',1)[0] + '.bam'
+ ' > ' + str(args_dict['bed_files']) + str(file).rsplit('.',1)[0] + '.bed')
"""Run BED creation manager"""
def create_bed(
args_dict):
# Add output directories
args_dict = add_directory(
args_dict,
'output',
'bed_files')
# Get list of files to convert based on acceptable file types
files = get_files(
args_dict['input'],
['.bam'])
# Convert aligned RNAseq reads to BED files
parallelize(
bed_convert,
files,
args_dict)
return args_dict