| 
0
 | 
     1 args <- commandArgs(trailingOnly = TRUE)
 | 
| 
 | 
     2 
 | 
| 
 | 
     3 imgt.dir = args[1]
 | 
| 
 | 
     4 merged.file = args[2]
 | 
| 
 | 
     5 gene = args[3]
 | 
| 
 | 
     6 
 | 
| 
 | 
     7 merged = read.table(merged.file, header=T, sep="\t", fill=T, stringsAsFactors=F)
 | 
| 
 | 
     8 
 | 
| 
 | 
     9 if(gene != "-"){
 | 
| 
 | 
    10 	merged = merged[grepl(paste("^", gene, sep=""), merged$best_match),]
 | 
| 
 | 
    11 } else {
 | 
| 
 | 
    12 	merged = merged[!grepl("unmatched", merged$best_match),]
 | 
| 
 | 
    13 }
 | 
| 
 | 
    14 
 | 
| 
 | 
    15 merged = merged[!grepl("unmatched", merged$best_match),]
 | 
| 
 | 
    16 
 | 
| 
 | 
    17 for(f in list.files(imgt.dir, pattern="*.txt$")){
 | 
| 
 | 
    18 	#print(paste("filtering", f))
 | 
| 
 | 
    19 	path = paste(imgt.dir, f, sep="")
 | 
| 
 | 
    20 	dat = read.table(path, header=T, sep="\t", fill=T, quote="", stringsAsFactors=F, check.names=FALSE)
 | 
| 
 | 
    21 	
 | 
| 
 | 
    22 	dat = dat[dat[,"Sequence ID"] %in% merged$Sequence.ID,]
 | 
| 
 | 
    23 	
 | 
| 
 | 
    24 	if(nrow(dat) > 0 & grepl("^8_", f)){ #change the FR1 columns to 0 in the "8_..." file
 | 
| 
 | 
    25 		dat[,grepl("^FR1", names(dat))] = 0
 | 
| 
 | 
    26 	}
 | 
| 
 | 
    27 	
 | 
| 
 | 
    28 	write.table(dat, path, quote=F, sep="\t", row.names=F, col.names=T, na="")
 | 
| 
 | 
    29 }
 |