align_mdb_template: Aligns molecular database mdb using template templ

Description Usage Arguments Examples

Description

Aligns molecular database mdb using template templ

Usage

1
align_mdb_template(mdb, templ, iimol = 1:length(mdb))

Arguments

mdb
templ
iimol

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

## The function is currently defined as
function (mdb, templ, iimol = 1:length(mdb)) 
{
    templ_ct <- mol_get_ct(templ)
    templ_lab <- mol_get_chelabs(templ)
    xyz_t <- mol2xyz(templ)
    mdb_a <- list()
    imol1 <- 0
    for (imol in iimol) {
        imol1 <- imol1 + 1
        mol <- mdb[[imol]]
        mol_ct <- mol_get_ct(mol)
        mol_lab <- mol_get_chelabs(mol)
        xyz_m <- mol2xyz(mol)
        isom_list <- find_substr_isomorph(templ_lab, templ_ct, 
            mol_lab, mol_ct)
        nisom <- length(isom_list)
        substr_mol <- substruct(mol, isom_list[[1]])
        xyz_ss <- mol2xyz(substr_mol)
        align <- align_arun(xyz_ss, xyz_t)
        xyz_ss_a <- transform_xyz(xyz_ss, align$R, align$T)
        rmse_a <- rmse4xyz(xyz_ss_a, xyz_t)
        align_best <- align
        rmse_a_best <- rmse_a
        if (nisom > 1) {
            for (isom in 2:nisom) {
                substr_mol <- substruct(mol, isom_list[[isom]])
                xyz_ss <- mol2xyz(substr_mol)
                align <- align_arun(xyz_ss, xyz_t)
                xyz_ss_a <- transform_xyz(xyz_ss, align$R, align$T)
                rmse_a <- rmse4xyz(xyz_ss_a, xyz_t)
                if (rmse_a < rmse_a_best) {
                  align_best <- align
                  rmse_a_best <- rmse_a
                }
            }
        }
        xyz_a <- transform_xyz(xyz_m, align_best$R, align_best$T)
        mol_a <- xyz2mol(mol, xyz_a)
        mdb_a[[imol1]] <- mol_a
        cat(sprintf("imol=%d imol1=%d nisom=%d detx=%g rmse1=%g rmse2=%g\n", 
            imol, imol1, nisom, align$detx, rmse4mol(substr_mol, 
                templ), rmse_a_best))
        flush.console()
    }
    mdb_a
  }

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