コード例 #1
0
ファイル: cmp_conf.c プロジェクト: GunnerLab/mcce3.0
int cmp_conf_hv(CONF conf1, CONF conf2, float IDEN_THR) {
    int iatom, jatom;
    float IDEN_THR2 = IDEN_THR*IDEN_THR;
    int n_hv1=0, n_hv2=0;
    //if (strcmp(conf1.confName, conf2.confName)) return -1;
    //if (conf1.n_atom != conf2.n_atom) return -1;
    /* check if they same number of heavy atoms */
    for (iatom = 0; iatom<conf1.n_atom; iatom++) {
        if (!conf1.atom[iatom].on) continue;
        if (conf1.atom[iatom].name[1] == 'H') continue;
        n_hv1++;
    }
    for (jatom = 0; jatom<conf2.n_atom; jatom++) {
        if (!conf2.atom[jatom].on) continue;
        if (conf2.atom[jatom].name[1] == 'H') continue;
        n_hv2++;
    }
    if (n_hv1!=n_hv2) return -1;
    
    for (iatom = 0; iatom<conf1.n_atom; iatom++) {
        if (!conf1.atom[iatom].on) continue;
        if (conf1.atom[iatom].name[1] == 'H') continue;
        
        for (jatom = 0; jatom<conf2.n_atom; jatom++) {
            if (!conf2.atom[jatom].on) continue;
            if (conf2.atom[jatom].name[1] == 'H') continue;
            
            if (strncmp(conf1.atom[iatom].name+1, conf2.atom[jatom].name+1, 2) ) continue;
            if (ddvv(conf1.atom[iatom].xyz, conf2.atom[jatom].xyz) < IDEN_THR2) break;
        }
        if (jatom == conf2.n_atom) return -1;
    }
    return 0;
}
コード例 #2
0
ファイル: cmp_conf.c プロジェクト: GunnerLab/mcce3.0
int cmp_conf(CONF conf1, CONF conf2, float IDEN_THR) {
    int iatom, jatom,n_on1,n_on2;
    float IDEN_THR2 = IDEN_THR*IDEN_THR;
    
    //if (strcmp(conf1.confName, conf2.confName)) return -1;
    if (conf1.n_atom != conf2.n_atom) return -1;
    
    n_on1 = 0;
    for (iatom = 0; iatom<conf1.n_atom; iatom++) {
        if (conf1.atom[iatom].on) n_on1++;
    }
    n_on2 = 0;
    for (jatom = 0; jatom<conf2.n_atom; jatom++) {
        if (conf2.atom[jatom].on) n_on2++;
    }
    if (n_on1 != n_on2) return -2;
    
    for (iatom = 0; iatom<conf1.n_atom; iatom++) {
        if (!conf1.atom[iatom].on) continue;
        for (jatom = 0; jatom<conf2.n_atom; jatom++) {
            if (!conf2.atom[jatom].on) continue;
            
            if (strncmp(conf1.atom[iatom].name+1, conf2.atom[jatom].name+1, 2) ) continue;
            if (fabs(conf1.atom[iatom].crg - conf2.atom[jatom].crg) > 1e-3) continue;
            if (ddvv(conf1.atom[iatom].xyz, conf2.atom[jatom].xyz) < IDEN_THR2) break;
        }
        if (jatom == conf2.n_atom) return -1;
    }
    return 0;
}
コード例 #3
0
ファイル: vdw.c プロジェクト: GunnerLab/mcce2.7
float vdw(ATOM atom1, ATOM atom2)
{
    float       e = 0;
    float       d2, d6, d12;      /* distance with power 2, 6, and 12 */
    float       C12, C6;
    char        pair[4];
    VECTOR      v1, v2;
    FILE        *debug_fp;

    if (!atom1.on) return e;
    if (!atom2.on) return e;

    v1 = atom1.xyz;
    v2 = atom2.xyz;

    d2 = ddvv(v1, v2);

    if (d2 > cutoff_far2)
        e = VDW_ELIMIT_FAR;             /* Cutoff */
    else if (d2 < cutoff_near2)
        e = VDW_ELIMIT_NEAR;            /* Cutoff */
    else
    {                                   /* 12-6 L-J potential */
        pair[0] = atom1.name[1];        /* element name */
        pair[1] = '-';
        pair[2] = atom2.name[1];        /* element name */
        pair[3] = '\0';

        if (param_get("VDWAMBER", "C12", pair, &C12)) {
            param_get("VDWAMBER", "C12", "X-X", &C12);
            debug_fp = fopen(env.debug_log,"a");
            fprintf(debug_fp, "VDWAMBER C12   %s  %16.6f\n", pair, C12);
            fclose(debug_fp);
            param_sav("VDWAMBER", "C12", pair, &C12,sizeof(C12));
        }

        if(param_get("VDWAMBER", "C6", pair, &C6)) {
            param_get("VDWAMBER", "C6", "X-X", &C6);
            debug_fp = fopen(env.debug_log,"a");
            fprintf(debug_fp, "VDWAMBER C6    %s  %16.6f\n", pair, C6);
            fclose(debug_fp);
            param_sav("VDWAMBER", "C6", pair, &C6,sizeof(C6));
        }

        d6 = d2*d2*d2;
        d12 = d6*d6;
        e = C12/d12 - C6/d6;
    }
    
    return e;
}
コード例 #4
0
ファイル: cmp_conf.c プロジェクト: GunnerLab/mcce3.0
float dist_conf_hv(CONF conf1, CONF conf2) {
    int iatom, jatom;
    float max_dist = 999.;
    float next_test_dist, test_dist2;
    int n_hv1=0, n_hv2=0;

    /* check if they have the same number of heavy atoms */
    for (iatom = 0; iatom<conf1.n_atom; iatom++) {
        if (!conf1.atom[iatom].on) continue;
        if (conf1.atom[iatom].name[1] == 'H') continue;
        n_hv1++;
    }
    for (jatom = 0; jatom<conf2.n_atom; jatom++) {
        if (!conf2.atom[jatom].on) continue;
        if (conf2.atom[jatom].name[1] == 'H') continue;
        n_hv2++;
    }
    if (n_hv1!=n_hv2) return 999.;
    
    next_test_dist = max_dist;
    while (1) {
        test_dist2 = next_test_dist*next_test_dist - 1e-4;
        next_test_dist = 0.;
        for (iatom = 0; iatom<conf1.n_atom; iatom++) {
            if (!conf1.atom[iatom].on) continue;
            if (conf1.atom[iatom].name[1] == 'H') continue;
            
            for (jatom = 0; jatom<conf2.n_atom; jatom++) {
                if (!conf2.atom[jatom].on) continue;
                if (conf2.atom[jatom].name[1] == 'H') continue;
                
                if (strncmp(conf1.atom[iatom].name+1, conf2.atom[jatom].name+1, 2) ) continue;
                if (ddvv(conf1.atom[iatom].xyz, conf2.atom[jatom].xyz) < test_dist2) break;
            }
            
            if (jatom >= conf2.n_atom) break; /* can't find a jatom within test_dist to match iatom */
            else {
                /* next test threshold is the maximum of all distances btw matched iatom and jatom */
                if (dvv(conf1.atom[iatom].xyz, conf2.atom[jatom].xyz) > next_test_dist) {
                    next_test_dist = dvv(conf1.atom[iatom].xyz, conf2.atom[jatom].xyz);
                }
            }
        }
        if (iatom < conf1.n_atom) { /* test_dist in the current loop is shorter than the distance btw i and j */
            break;
        }
    }
    return sqrt(test_dist2+1e-4);
}
コード例 #5
0
ファイル: vdw.c プロジェクト: GunnerLab/mcce2.7
float vdw_sim(ATOM atom1, ATOM atom2)
{   float f1 = env.vdwf1, f2 = env.vdwf2;   
                                /* vdw constants
                                 * vdw = epsilon((sigma/(r1+r2))^12 - (sigma/(r1+r2))^6)
                                 * f1: sigma=f1*(r1+r2)
                                 * f2: epsilon=f2
                                 */

    float       e = 0;
    float       d2, d6, d12;      /* distance with power 2, 6, and 12 */
    float       C12, C6;
    float s, s6, s12;
    VECTOR      v1, v2;

    if (!atom1.on) return e;
    if (!atom2.on) return e;

    v1 = atom1.xyz;
    v2 = atom2.xyz;

    d2 = ddvv(v1, v2);

    if (d2 > cutoff_far2)
        e = VDW_ELIMIT_FAR;             /* Cutoff */
    else if (d2 < cutoff_near2)
        e = VDW_ELIMIT_NEAR;            /* Cutoff */
    else
    {                                   /* 12-6 L-J potential */
        d6 = d2*d2*d2;
        d12 = d6*d6;

        s =  f1*(atom1.rad+atom1.rad);
        s6 = s*s*s*s*s*s;
        s12= s6*s6;

        C12=f2*s12;
        C6 =f2*s6;

        e = C12/d12 - C6/d6;
    }

    return e;
}
コード例 #6
0
ファイル: vdw.c プロジェクト: GunnerLab/mcce2.7
VECTOR vdw_frc(VECTOR v1, VECTOR v2, float C6, float C12) { 
    
    VECTOR frc;
    float d2, d4, d8, d14;
    VECTOR frc6,frc12;
    
    d2 = ddvv(v1, v2);
    if (d2 > cutoff_far2)  {frc.x=0;frc.y=0;frc.z=0;return frc;}
    if (d2 < cutoff_near2) d2 = cutoff_near2;
    
    d4 = d2*d2;
    d8 = d4*d4;
    d14 = d8*d4*d2;
    
    frc12 = vector_rescale(vector_vminusv(v2,v1), (-12.*C12/d14));
    frc6  = vector_rescale(vector_vminusv(v2,v1), (  6.*C6/d8));
    frc = vector_vplusv(frc12, frc6);
    return frc;
}
コード例 #7
0
ファイル: cmp_conf.c プロジェクト: GunnerLab/mcce3.0
float rmsd_conf_hv(CONF conf1, CONF conf2) {
    int iatom, jatom;
    int n_hv1=0, n_hv2=0;
    float sum_distsq;
    
    /* check if they have the same number of heavy atoms */
    for (iatom = 0; iatom<conf1.n_atom; iatom++) {
        if (!conf1.atom[iatom].on) continue;
        if (conf1.atom[iatom].name[1] == 'H') continue;
        n_hv1++;
    }
    for (jatom = 0; jatom<conf2.n_atom; jatom++) {
        if (!conf2.atom[jatom].on) continue;
        if (conf2.atom[jatom].name[1] == 'H') continue;
        n_hv2++;
    }
    if (n_hv1!=n_hv2) return 999.;
    if (n_hv1 == 0) return 0.;
    
    sum_distsq = 0.;
    for (iatom = 0; iatom<conf1.n_atom; iatom++) {
        if (!conf1.atom[iatom].on) continue;
        if (conf1.atom[iatom].name[1] == 'H') continue;
        
        for (jatom = 0; jatom<conf2.n_atom; jatom++) {
            if (!conf2.atom[jatom].on) continue;
            if (conf2.atom[jatom].name[1] == 'H') continue;
            
            if (!strcmp(conf1.atom[iatom].name, conf2.atom[jatom].name)) break;
        }
        if (jatom >= conf2.n_atom) return 999.; /* can't find a jatom to match iatom */
        
        sum_distsq += ddvv(conf1.atom[iatom].xyz, conf2.atom[jatom].xyz);
    }
    
    return sqrt(sum_distsq/(float) n_hv1);
}
コード例 #8
0
ファイル: sas_native.c プロジェクト: GunnerLab/mcce2.7
int mkacc(ATOM *atom)
{
  VECTOR point;
  int i, j, k, l, m;
  float d_square;
  int count;
  int ix, iy, iz;
  int ax, ay, az;         /* the grid index of this atom */
  int status;

  count = num_pts;

  ax = (int) ((atom -> xyz.x - xyz_min.x) / grid_interval);
  ay = (int) ((atom -> xyz.y - xyz_min.y) / grid_interval);
  az = (int) ((atom -> xyz.z - xyz_min.z) / grid_interval);

  /* loop over each point */

  for (m = 0; m < num_pts; m++) {
    status = TRUE;

    point.x = point_preset[m][0] * atom -> rad + atom -> xyz.x;
    point.y = point_preset[m][1] * atom -> rad + atom -> xyz.y;
    point.z = point_preset[m][2] * atom -> rad + atom -> xyz.z;

    /* find out which grid this point belongs to */
    ix = (int) ((point.x - xyz_min.x) / grid_interval);
    iy = (int) ((point.y - xyz_min.y) / grid_interval);
    iz = (int) ((point.z - xyz_min.z) / grid_interval);

    if (grid[ix][iy][iz].n_atom >= 1) {
      for (l = 0; l < grid[ix][iy][iz].n_atom; l++) {
        if (grid[ix][iy][iz].atom[l].on &&
            status == TRUE &&
            (ix != ax || iy != ay || iz != az ||
             memcmp(atom, &(grid[ix][iy][iz].atom[l]), sizeof(ATOM)))) {
            d_square = ddvv(point, grid[ix][iy][iz].atom[l].xyz);
            if (d_square < grid[ix][iy][iz].atom[l].rad * grid[ix][iy][iz].atom[l].rad) {
              status = FALSE;
              count --;
            }
        }
      }
    }

    for (i = ix - 1; i <= ix + 1; i++) {
      if (status == FALSE) break;
      for (j = iy - 1; j <= iy + 1; j++) {
        if (status == FALSE) break;
        for (k = iz - 1; k <= iz + 1; k++) {
          if (status == FALSE) break;
          for (l = 0; l < grid[i][j][k].n_atom; l++) {
            if (grid[i][j][k].atom[l].on && status == TRUE) {
               if (i != ax || j != ay || k != az ||
                   memcmp(atom, &(grid[i][j][k].atom[l]), sizeof(ATOM))) {
                  d_square = ddvv(point, grid[i][j][k].atom[l].xyz);
                  if (d_square < grid[i][j][k].atom[l].rad * grid[i][j][k].atom[l].rad) {
                      status = FALSE;
                      count --;
	           }
               }
            }
          }
        }
      }
    }
  }

  atom->sas = (float) count/num_pts;

  return 0;
}
コード例 #9
0
ファイル: relax_water.cpp プロジェクト: zxiaoyao/mcce-delphi
int relax_water(PROT prot) {
    int i_res,i_conf,i_atom,j_res,j_conf,j_atom,k_res,k_conf,k_atom;
    int n_conf, add, counter;
    FILE *debug_fp;

    for (i_res=0; i_res<prot.n_res; i_res++) {
        RES *ires_p = &prot.res[i_res];
        if (strcmp(prot.res[i_res].resName, "HOH")) continue;
	n_conf = prot.res[i_res].n_conf;
        counter = 0;
        for (i_conf=1; i_conf<n_conf; i_conf++) {
            CONF *iconf_p = &prot.res[i_res].conf[i_conf];
	    if (!iconf_p->n_atom) continue;
            
            for (j_res=0; j_res<prot.n_res; j_res++) {
                if (!strcmp(prot.res[j_res].resName, "HOH")) continue;
                for (j_conf=0; j_conf<prot.res[j_res].n_conf; j_conf++) {
                    CONF *jconf_p = &prot.res[j_res].conf[j_conf];
                    ATOM *iatom_p;
                    
                    CONF conf;
                    conf.n_atom = iconf_p->n_atom;
                    conf.atom  = (ATOM *) malloc(conf.n_atom*sizeof(ATOM));
                    cpy_conf(&conf,iconf_p);
                    for (i_atom=0;i_atom<conf.n_atom;i_atom++) {
                        if (!conf.atom[i_atom].on) continue;
                        if (conf.atom[i_atom].name[1] == 'O') break;
                    }
                    if (i_atom<conf.n_atom) iatom_p = &conf.atom[i_atom];
                    else break;
                    
                    add = 0;
                    for (j_atom=0; j_atom<prot.res[j_res].conf[j_conf].n_atom; j_atom++) {
                        ATOM *jatom_p = &jconf_p->atom[j_atom];
			if (!jatom_p->on) continue;
                        if (jatom_p->name[1] == 'H') continue;
                        if (ddvv(iatom_p->xyz,jatom_p->xyz) > RELAX_THR2) continue;
                        add = 1;

                        for (i_atom=0;i_atom<conf.n_atom;i_atom++) {
                            if (!conf.atom[i_atom].on) continue;
                            
                            conf.atom[i_atom].xyz = 
                            vector_vplusv(jatom_p->xyz,
                            vector_rescale(vector_normalize(
                            vector_vminusv(conf.atom[i_atom].xyz, jatom_p->xyz)), env.water_relax_thr));
                        }
                        
                        /*
                        ins_conf(ires_p, ires_p->n_conf, iconf_p->n_atom);
                        iconf_p = &prot.res[i_res].conf[i_conf];
                        if (cpy_conf(&ires_p->conf[ires_p->n_conf-1], &ires_p->conf[i_conf])) {printf("   Error! relax_water(): couldn't copy the conformer \"%s\" in residue %s %d, to new position k_conf = %d\n",ires_p->conf[i_conf].confName,ires_p->resName, ires_p->resSeq, ires_p->n_conf-1); return USERERR;}

                        
                        for (i_conf2=1; i_conf2<ires_p->n_conf-1; i_conf2++) {
                            if (!cmp_conf(ires_p->conf[i_conf2], ires_p->conf[ires_p->n_conf-1],0.05)) break;
                        }
                        if ( i_conf2 < ires_p->n_conf-1 ) {
                            del_conf(ires_p, ires_p->n_conf-1);
                            iconf_p = &prot.res[i_res].conf[i_conf];
                            continue;
                        }
                        */
                        //printf("   Debugging! residue %s%4d nconf=%d, residue %s%4d, distance %8.3f\n", prot.res[i_res].resName,prot.res[i_res].resSeq,ires_p->n_conf, prot.res[j_res].resName,prot.res[j_res].resSeq,dvv(iatom_p->xyz,jatom_p->xyz));
                    }
                    
                    if (add) {
                    for (j_atom=0; j_atom<prot.res[j_res].conf[j_conf].n_atom; j_atom++) {
                        ATOM *jatom_p = &jconf_p->atom[j_atom];
			if (!jatom_p->on) continue;
                        if (jatom_p->name[1] == 'H') continue;
                        if (ddvv(iatom_p->xyz,jatom_p->xyz) > RELAX_THR2) continue;
                        add = 0;
                    }
                    }
                    
                    if (add) {
                    for (k_conf=1; k_conf<ires_p->n_conf; k_conf++) {
                        if (!cmp_conf(ires_p->conf[k_conf], conf, 0.05)) break;
                    }
                    if ( k_conf<ires_p->n_conf ) add = 0;
                    }
                    
                    if (add) {
                    for (k_res=0; k_res<prot.n_res; k_res++) {
                        k_conf = 0;
                        for (k_atom=0; k_atom<prot.res[k_res].conf[k_conf].n_atom; k_atom++) {
                            ATOM *katom_p = &prot.res[k_res].conf[k_conf].atom[k_atom];
                            if (!katom_p->on) continue;
                            if (katom_p->name[1] == 'H') continue;
                            if (ddvv(iatom_p->xyz,katom_p->xyz) > RELAX_THR2) continue;
                            add = 0;
                        }
                    }
                    }

                    if (add) {
                        counter++;
                        ins_conf(ires_p, ires_p->n_conf, conf.n_atom);
                        iconf_p = &prot.res[i_res].conf[i_conf];
                        if (cpy_conf(&ires_p->conf[ires_p->n_conf-1], &conf)) {printf("   Error! relax_water(): couldn't copy a new conformer \"%s\" in residue %s %d, to new position k_conf = %d\n",conf.confName,ires_p->resName, ires_p->resSeq, ires_p->n_conf-1); return USERERR;}
                        debug_fp = fopen(env.debug_log,"a");
                        fprintf(debug_fp,"add conformer to HOH %c%04d to relax against %s %c%04d\n",ires_p->chainID,ires_p->resSeq,prot.res[j_res].resName,prot.res[j_res].chainID,prot.res[j_res].resSeq);
                        fclose(debug_fp);
                    }
                    
                    free(conf.atom);
                }
            }
            
        }
    }
    return 0;
}