cmf_pred_anal_atoms: Making predictions with analysus of ampacts of each atom

Description Usage Arguments Examples

Description

Making predictions with analysus of ampacts of each atom

Usage

1
2
3
4
5
6
7
cmf_pred_anal_atoms(
  train_fname = "ligands-train.mol2",  # Training set file name
  pred_fname = "ligands-pred.mol2",    # Prediction set file name
  imol = 1,                            # Molecule from file pred_fname to be analyzed
  model_fname = "ligands-model.RData", # Model file name
  ...
)

Arguments

train_fname

"ligands-train.mol2"

pred_fname

"ligands-pred.mol2"

imol

1

model_fname

"ligands-model.RData"

...

Examples

 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
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
cmf_pred_anal_atoms <- function
(
  train_fname = "ligands-train.mol2",  # Training set file name
  pred_fname = "ligands-pred.mol2",    # Prediction set file name
  imol = 1,                            # Molecule from file pred_fname to be analyzed
  model_fname = "ligands-model.RData", # Model file name
  ...
)
{
  mdb0_train <- read_mol2(train_fname)
  mdb0_pred <- read_mol2(pred_fname)
  mdb_train <- cmf_params_tripos(mdb0_train)
  mdb_pred <- cmf_params_tripos(mdb0_pred)
  ntrain <- length(mdb_train)
  
  load(model_fname)
  mfields <- names(model$h)
  nfields <- length(mfields)

  mol1 <- mdb_pred[[imol]]
  natoms1 <- length(mol1$atoms)
  atom_contr <<- array(0.0, c(natoms1, nfields))
  for (iatom1 in 1:natoms1) {
    atom1 <- mol1$atoms[[iatom1]]
	val_all <- 0.0
	for (f in 1:nfields) {
	  field <- mfields[f]
	  val_fld <- 0.0
	  for (imol2 in 1:ntrain) {
	    mol2 <- mdb_train[[imol2]]
		natoms2 <- length(mol2$atoms)
		for (iatom2 in 1:natoms2) {
		  atom2 <- mol2$atoms[[iatom2]]
		  if (field %in% tripos_atom_types) {
		    kern <- cmf_aa_ind_kernel(field, atom1, atom2, model$alpha[[field]])
		  } else {
		    kern <- cmf_aa_kernel(field, atom1, atom2, model$alpha[[field]])
		  }
		  val_fld <- val_fld + model$h[[field]] * model$a[imol2] * kern
		}
	  }
	  val_all <- val_all + val_fld
	  atom_contr[iatom1, f] <<- val_fld
	}
	cat(sprintf("%d\t%s\t%g\n", iatom1, atom1$syb, val_all)); flush.console()
  }
  y_pred <- sum(atom_contr) + model$b
  cat(sprintf("bias=%g\n", model$b))
  cat(sprintf("y_pred=%g\n", y_pred))
  
  # Visualization
  mol_view_cpk(mol1)
  mol_view_cylindres(mol1)
  for (iatom1 in 1:natoms1) {
    atom1 <- mol1$atoms[[iatom1]]
	contr <- sum(atom_contr[iatom1,])
	spheres3d(atom1$x, atom1$y, atom1$z, color = if (contr>0) "red" else "blue", radius=abs(contr), alpha=0.5)
	if (abs(contr) > 0.2) {
	  label <- sprintf("%d", iatom1)
	  shiftx <- 0.3
	  shifty <- 0.3
	  shiftz <- 0.3
	  text3d(atom1$x+shiftx, atom1$y+shifty, atom1$z+shiftz, color="black", text=label)
	}
  }
  }

conmolfields documentation built on May 2, 2019, 4:18 p.m.