forked from sdparekh/zUMIs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckyaml.R
More file actions
executable file
·137 lines (115 loc) · 3.4 KB
/
checkyaml.R
File metadata and controls
executable file
·137 lines (115 loc) · 3.4 KB
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
132
133
134
135
136
137
#!/usr/bin/env Rscript
suppressMessages(require(yaml))
y<-commandArgs(trailingOnly = T)
inp<-try(read_yaml(y),silent = T)
e=0
if(grepl("try-error",class(inp))) {
e=1
print(e)
stop()
}
## Check if mandatory parameters have arguments
if(is.null(inp$project)) {
e=1
print("Please provide a project name. It can not be NULL.")
}
if(is.null(inp$reference$STAR_index)) {
e=1
print("Please provide path to STAR index directory. It can not be NULL.")
}
if(is.null(inp$reference$GTF_file)) {
e=1
print("Please provide path to GTF file. It can not be NULL.")
}
if(is.null(inp$out_dir)) {
e=1
print("Please provide path to output directory. It can not be NULL.")
}
if(is.null(unlist(inp$sequence_files))) {
e=1
print("You need to provide atleast two input fastq files and their base definitions.")
}
lapply(inp$sequence_files, function(x) {
if(is.null(x$name) | is.null(x$base_definition)){
e=1
print("You can not leave out file name or base definition.")
}
} )
print(
paste(sapply(inp$sequence_files, function(x)
if(is.null(unlist(x$base_definition))) {
e=1
print("You need to provide base definition for all input files")
}else { print("")}
)))
print(
paste(
lapply(seq_along(inp$sequence_files),
function(x) {
if(is.null(unlist(inp$sequence_files[[x]]$name))) {
e=1
print(paste(print(names(inp$sequence_files[x])),": You need to provide path to the input file"))
}else{ print("")}
})
))
print(
paste(
lapply(seq_along(inp$sequence_files),
function(x) {
if(is.null(unlist(inp$sequence_files[[x]]$base_definition))) {
e=1
print(paste(print(names(inp$sequence_files[x])),": You need to provide base definitions for this input file"))}
})
)
)
lapply(inp$sequence_files,
function(x) {
if(!is.null(x$base_definition)) {
if(any(!grepl("^BC|^UMI|^cDNA",x$base_definition))) {
e=1
print("The base definition can only be BC/cDNA/UMI. Check if you have a typo/special characters in your base definition or you forgot to add /space/ after -. Refer to the example yaml.")
}
}
})
## Check if all the file paths are correct
lapply(inp$sequence_files,
function(x) {
if(!is.null(x$name)) {
if(!file.exists(x$name)) {
e=1
print("Please check fastq file paths.")
}
}
})
if(!is.null(inp$reference$GTF_file)) {
if(!file.exists(inp$reference$GTF_file)) {
e=1
print("GTF file does not exists")
}
}
if(!is.null(inp$reference$STAR_index)) {
if(!file.exists(inp$reference$STAR_index)) {
e=1
print("STAR index does not exists")
}
}
if(!is.null(inp$barcodes$barcode_file)){
if(!file.exists(inp$barcodes$barcode_file)) {
e=1
print("Please check barcode list file path.")
}
}
## Some other variable's validity check
if(!is.numeric(inp$num_threads)) {
e=1
print("Number of threads should be a number.")
}
if(!inp$num_threads >= 1) {
e=1
print("Number of threads should be a number >= 1")
}
if(!grepl("Filtering|Mapping|Counting|Summarising",inp$which_Stage,ignore.case = T)) {
e=1
print("which_stage argument can only be one of these terms: Filtering, Mapping, Counting, Summarising")
}
print(e)