-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsRNA_fragment_timing.py
122 lines (94 loc) · 3.73 KB
/
sRNA_fragment_timing.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import os
import yaml
import time
import pandas as pd
from basics import *
from datetime import timedelta
from collections import defaultdict
# Import the variables
timing_module = timing()
run_name = "mm_snoRNA"
with open("sRNA_frag_config.yaml", "r") as file:
config_vars = yaml.safe_load(file)
## -- Config Variables -- ##
P1_bool = config_vars['module_options']['P1']['bool']
S1_bool = config_vars['module_options']['S1']['bool']
P2_bool = config_vars['module_options']['P2']['bool']
out_dir = config_vars['dir_locations']['out_dir']
working_dir = config_vars["dir_locations"]["working_dir"]
sample_dir =config_vars["dir_locations"]["sample_dir"]
delete_working = config_vars['module_options']["delete_working"]
make_summary = config_vars["module_options"]["SUMMARY"]
# Confirm that dir exists
os.system("mkdir " + out_dir)
os.system("mkdir " + working_dir)
if os.path.isdir(out_dir) == False:
raise ValueError("Out dir does not exist")
if os.path.isdir(working_dir) == False:
raise ValueError("Working dir does not exist")
if os.path.isdir(sample_dir) == False:
raise ValueError("Sample directory does not exist")
## -- Config Variables -- ##
if P2_bool == True:
os.system("cp sRNA_frag_config.yaml " + out_dir + ";\
cp sRNA_fragment_P2.py " + out_dir + ";\
cp gtf_groundtruth.py " + out_dir + ";\
cp gtf_modifiers.py " + out_dir + ";\
cp conversion_tools.py " + out_dir + ";\
cp alias_work.py " + out_dir + ";\
cp basics.py " + out_dir)
if P1_bool == True:
print("User can start running next instance of sRNAfrag.")
os.system("python sRNA_fragment_P1.py")
timing_module.take_time("P1")
if S1_bool == True:
os.system("cp scripts/.S1_figures.R " + out_dir + ";\
cd " + out_dir + ";\
Rscript .S1_figures.R")
timing_module.take_time("S1")
if P2_bool == True:
# Copy bash script for edge case where there are over 8000 fragments detected
os.system("mkdir " + working_dir + "/aligned_sams")
os.system("cp scripts/.add_prefix_outspace.sh " + working_dir + "/aligned_sams")
os.system("cd " + out_dir + ";\
python sRNA_fragment_P2.py")
timing_module.take_time("P2")
# Clean up Module
if P1_bool == True:
os.system("cd " + out_dir + ";\
mkdir tables;\
mv sRNA_frag_counts.csv tables;\
mv num_reads_bam.csv tables")
if S1_bool == True:
os.system("cd " + out_dir + ";\
mkdir figures;\
mv S1_std_loci.jpeg figures;\
mv S1_motifs_counts.jpeg figures;\
mv S1_freq_motifs.jpeg figures;\
mv S1_five-mer_5p.html figures;\
mv S1_five-mer_3p.html figures;\
mv S1_correction_density.jpeg figures;\
mv filtered_corrected_counts.csv tables;\
mv filtered_counts.csv tables")
if P2_bool == True:
os.system("cd " + out_dir + ";\
mkdir int_files;\
mkdir sequences;\
mv sRNA_frag_config.yaml int_files;\
mv *.py int_files;\
mv *.R int_files;\
mv merged_counts.csv tables;\
mv annotated_ref_table.csv tables;\
mv filtered_sequences.fa sequences;\
mv ref_table.csv tables;\
mv P2_cluster_start_end_disagreement.jpeg figures;\
mv alternate_peaks.csv tables;\
mv cluster_peak_relationship_table.csv tables;\
mv P2_Filter_Passing_Hist.jpeg figures")
if delete_working == True:
os.system("rm -rf " + working_dir)
if make_summary == True:
os.system("cp scripts/summary.md " + out_dir + ";\
cd " + out_dir + ";\
python -m markdown summary.md > summary.html")
timing_module.export(run_name)