-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtrend_analysis.py
131 lines (94 loc) · 5.55 KB
/
trend_analysis.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
123
124
125
126
127
128
129
130
131
"""Trend Analysis tool"""
import argparse
import scripts.upload
import scripts.delete
# Upload functions
def upload_raw_data(args):
"""Upload raw run data to the database"""
if args.overwrite:
scripts.delete.run_all.del_all_rundata(args.path)
scripts.upload.raw_data.up_to_database(args.path)
else:
scripts.upload.raw_data.up_to_database(args.path)
def upload_processed_data(args):
"""Upload processed run data to the database"""
scripts.upload.run_processed.up_to_database(args.path)
def upload_sample_processed(args):
"""Upload processed sample data to the database"""
scripts.upload.sample_processed.up_to_database(args.path, args.samples)
# Delete frunctions
def delete_run_all_data(args):
"""Delete run data from the whole database"""
scripts.delete.run_all.del_all_rundata(args.path)
def delete_run_raw_data(args):
"""Delete raw run data from the database"""
scripts.delete.run_rawdata.del_run_rawdata(args.path)
def delete_sample_proc_data(args):
"""Delete processed samples from the database"""
scripts.delete.sample_processed.del_sampledata(args.path, args.samples)
def delete_run_proc_data(args):
"""Delete processed run data"""
scripts.delete.run_processed.del_runprocessed(args.path)
# Delete + upload functions
def update_run_data(args):
"""Delete and then upload all run data"""
scripts.delete.run_all.del_all_rundata(args.path_raw)
scripts.upload.raw_data.up_to_database(args.path_raw)
scripts.upload.run_processed.up_to_database(args.path_proc)
def update_proc_run_data(args):
"""Delete and then upload processed run data"""
scripts.delete.run_processed.del_runprocessed(args.path)
scripts.upload.run_processed.up_to_database(args.path)
def update_sample_proc_data(args):
"""Delete and then upload processed sample data"""
scripts.delete.sample_processed.del_sampledata(args.path, args.samples)
scripts.upload.sample_processed.up_to_database(args.path, args.samples)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
subparser = parser.add_subparsers()
# upload data
parser_upload = subparser.add_parser('upload', help='Upload data to database')
subparser_upload = parser_upload.add_subparsers()
parser_upload_raw = subparser_upload.add_parser('raw_data', help='upload raw data to database')
parser_upload_raw.add_argument('--overwrite', help='overwrite data in the database', action='store_true')
parser_upload_raw.add_argument('path', help='Path to run')
parser_upload_raw.set_defaults(func=upload_raw_data)
parser_upload_processed = subparser_upload.add_parser('processed_data', help='upload processed data to database')
parser_upload_processed.add_argument('path', help='Path to run')
parser_upload_processed.set_defaults(func=upload_processed_data)
parser_upload_samples_proc = subparser_upload.add_parser('sample_processed', help='upload processed sample data to database')
parser_upload_samples_proc.add_argument('path', help='Path to run')
parser_upload_samples_proc.add_argument('samples', default=[], nargs='+', help='Sample names')
parser_upload_samples_proc.set_defaults(func=upload_sample_processed)
# delete data
parser_delete = subparser.add_parser('delete', help='Delete data from database')
subparser_delete = parser_delete.add_subparsers()
parser_delete_run_all = subparser_delete.add_parser('run_all', help='delete run data from all tables in database')
parser_delete_run_all.add_argument('path', help='Path to run')
parser_delete_run_all.set_defaults(func=delete_run_all_data)
parser_delete_raw_run = subparser_delete.add_parser('raw_run', help='delete raw run data from the database')
parser_delete_raw_run.add_argument('path', help='Path to run')
parser_delete_raw_run.set_defaults(func=delete_run_raw_data)
parser_delete_sample_proc = subparser_delete.add_parser('sample_proc', help='delete processed sample data from the database')
parser_delete_sample_proc.add_argument('path', help='Path to run')
parser_delete_sample_proc.add_argument('samples', default=[], nargs='+', help='Sample names')
parser_delete_sample_proc.set_defaults(func=delete_sample_proc_data)
parser_delete_run_proc = subparser_delete.add_parser('run_proc', help='delete processed run data from the database')
parser_delete_run_proc.add_argument('path', help='Path to run')
parser_delete_run_proc.set_defaults(func=delete_run_proc_data)
# update data
parser_update = subparser.add_parser('update', help='Delete and update data')
subparser_update = parser_update.add_subparsers()
parser_update_sample_proc = subparser_update.add_parser('sample', help='delete and update processed sample data')
parser_update_sample_proc.add_argument('path', help='Path to run')
parser_update_sample_proc.add_argument('samples', default=[], nargs='+', help='Sample names')
parser_update_sample_proc.set_defaults(func=update_sample_proc_data)
parser_update_run = subparser_update.add_parser('run_all', help='delete and update all run data')
parser_update_run.add_argument('path_raw', help='Path to raw run')
parser_update_run.add_argument('path_proc', help='Path to processed run')
parser_update_run.set_defaults(func=update_run_data)
parser_update_proc_run = subparser_update.add_parser('proc_run', help='delete and update processed run data')
parser_update_proc_run.add_argument('path', help='Path to processed run')
parser_update_proc_run.set_defaults(func=update_proc_run_data)
args = parser.parse_args()
args.func(args)