52
|
1 args <- commandArgs(trailingOnly = TRUE)
|
|
2
|
|
3 print(args)
|
|
4
|
|
5 inputs = args[1:(length(args) - 1)]
|
|
6 output = args[length(args)]
|
|
7
|
|
8 current.id = ""
|
|
9 counter = 1
|
|
10
|
|
11 result = NULL
|
|
12
|
|
13 for(current in inputs){
|
|
14 if(grepl("/", current)){ #its a path to a file
|
|
15 print(paste("Adding file", counter, "to", current.id))
|
|
16 dat = read.table(current, sep="\t", header=T, quote="", fill=T)
|
|
17
|
|
18 if(nrow(dat) == 0){
|
|
19 print(paste(counter, "of", current.id, "has no sequences, skipping"))
|
|
20 next
|
|
21 }
|
|
22
|
|
23 #IMGT check
|
|
24
|
|
25 dat$Sample = current.id
|
|
26 dat$Replicate = counter
|
|
27
|
|
28 if(is.null(result)){
|
|
29 result = dat[NULL,]
|
|
30 }
|
|
31
|
|
32 result = rbind(result, dat)
|
|
33
|
|
34 counter = counter + 1
|
|
35
|
|
36 } else { #its an ID of a patient
|
|
37 print(paste("New patient", current))
|
|
38 current.id = current
|
|
39 counter = 1
|
|
40 }
|
|
41 }
|
|
42
|
|
43 write.table(result, output, sep="\t", quote=F, row.names=F, col.names=T)
|