annotate PLIDflow/scripts/pdbcenter_npts_finder.R @ 3:d45ae17b4470 draft

Removed modeller which was not necessary anymore
author bitlab
date Mon, 27 Jan 2020 02:49:46 -0500
parents 6fcfa4756040
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
1 #pdbcenter_npts_finder.R calculates the geometric center of a PDB file
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
2
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
3 #!/usr/bin/env Rscript
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
4 args = commandArgs(trailingOnly=TRUE)
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
5
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
6 if(length(args) < 1){
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
7 stop("USE: Rscript pdbcenter_npts_finder.R <receptor_name> <session_dir>")
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
8 }
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
9
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
10 #Arguments definition
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
11 receptor_name <- args[1]
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
12 session_dir <- args[2]
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
13
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
14 #Read PDB file
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
15 archivo <- scan(args[1], what = character(), quiet = TRUE)
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
16
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
17 #Make a table where positions of carbon (C) atoms and their x, y, z coordenates will be placed
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
18 salto <- 0
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
19 for(i in 1:(length(archivo)-2)){
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
20 if(archivo[i] == "ATOM" && archivo[i+2] == "C"){
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
21 salto <- salto + 1
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
22 }
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
23 }
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
24 tablaC <- matrix(1, nrow = salto, ncol = 4)
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
25
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
26 #Header. Note: first column: C atom position (will be filled in when the number of C will be known)
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
27 #Row labels
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
28 colnames(tablaC) <- c("C Position","X", "Y", "z")
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
29 rownames(tablaC) <- 1:salto
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
30
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
31 #Fill in tablaC with x, y,z coordenates of the C atoms as numeric
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
32 salto <- 0
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
33 posicionC <- c()
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
34 for(i in 1:(length(archivo)-2)){
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
35 if(archivo[i] == "ATOM" && archivo[i+2] == "C"){
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
36 salto <- salto + 1
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
37 posicionC <- c(posicionC, archivo[i+1])
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
38
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
39 tablaC[salto,2] <- as.numeric(archivo[i+6])
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
40 tablaC[salto,3] <- as.numeric(archivo[i+7])
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
41 tablaC[salto,4] <- as.numeric(archivo[i+8])
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
42 }
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
43 }
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
44
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
45 #Add C atom positions in the column 1
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
46 for(i in 1:salto){
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
47 tablaC[i,1] <- as.numeric(posicionC[i])
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
48 }
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
49
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
50 #Geometric center calculation as grid center x, y, z to be introduced in the GPF file
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
51 pto_x_medio <- (max(tablaC[,2]) + min(tablaC[,2]))/2
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
52 pto_y_medio <- (max(tablaC[,3]) + min(tablaC[,3]))/2
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
53 pto_z_medio <- (max(tablaC[,4]) + min(tablaC[,4]))/2
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
54
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
55 pto_x_medio_r <- round(pto_x_medio,digits=3)
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
56 pto_y_medio_r <- round(pto_y_medio,digits=3)
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
57 pto_z_medio_r <- round(pto_z_medio,digits=3)
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
58
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
59 #print(paste(pto_x_medio_r, pto_y_medio_r, pto_z_medio_r, sep = ";"))
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
60
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
61 #Calculate distances in each coordenate to have de number of points (npts) x, y, z to be introduced in the GPF file
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
62 eu_x <- max(tablaC[,2])-min(tablaC[,2])
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
63 eu_y <- max(tablaC[,3])-min(tablaC[,3])
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
64 eu_z <- max(tablaC[,4])-min(tablaC[,4])
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
65
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
66 eu_x_r <- round(eu_x,digits=0)
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
67 eu_y_r <- round(eu_y,digits=0)
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
68 eu_z_r <- round(eu_z,digits=0)
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
69
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
70 #print(paste(eu_x, eu_y, eu_z, sep = ";"))
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
71 #print(paste(eu_x_r, eu_y_r, eu_z_r, sep = ";"))
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
72
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
73 if(eu_x > 126 || eu_y > 126 || eu_x > 126){
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
74 print("At least one dimension in number of points is out of range (>126) according AutoDock software")
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
75 break
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
76 }
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
77
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
78 #Write PDB geometric center and eu_x_r, eu_y_r, eu_z_r in a file
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
79 #write(paste(pto_x_medio_r, pto_y_medio_r, pto_z_medio_r, eu_x_r, eu_y_r, eu_z_r,sep= "\n"), file = "/home/galaxy/galaxy/tools/proteindocking/scripts/pdbcenter_npts.txt")
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
80 write(paste(pto_x_medio_r, pto_y_medio_r, pto_z_medio_r, eu_x_r, eu_y_r, eu_z_r,sep= "\n"), file = "pdbcenter_npts.txt")
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
81
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
82
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
83
6fcfa4756040 Uploaded
bitlab
parents:
diff changeset
84