label_chem.c
来自「最经典的分子对结软件」· C语言 代码 · 共 621 行 · 第 1/2 页
C
621 行
label_count++; else exit (fprintf (global.outfile, "ERROR get_table: %s found in %s, but not defined in %s\n", table_label[label_count], table_file_name, label_chemical->file_name)); } else exit (fprintf (global.outfile, "ERROR get_table: Empty line encountered in %s\n", table_file_name)); } rewind (table_file); while (strncmp (line, "table", 5)) if (!fgets (line, 100, table_file)) exit (fprintf (global.outfile, "ERROR get_table: No table found in %s\n", table_file_name)); for (i = 0; i < label_count; i++) { if (!fgets (line, 100, table_file)) exit (fprintf (global.outfile, "ERROR get_table: Table empty in %s\n", table_file_name));/** Replace tab characters in input line with spaces* 6/95 te*/ white_line (line); for (j = 0, token_arg = line; j <= i; j++, token_arg = NULL) { if (token = strtok (token_arg, " ")) (*table)[label_conversion[i]][label_conversion[j]] = (*table)[label_conversion[j]][label_conversion[i]] = atof (token); else exit (fprintf (global.outfile, "ERROR get_table: Insufficient table entries in %s\n", table_file_name)); } } fclose (table_file); efree ((void *) &label_conversion); efree ((void *) &table_label);/** Print out match table * 6/95 te*/ fprintf (global.outfile, "\n____________Chemical_Table____________\n\n"); fprintf (global.outfile, " _"); for (i = 0; i < label_chemical->total; i++) fprintf (global.outfile, "%6s", "______"); fprintf (global.outfile, "_\n"); fprintf (global.outfile, " | "); for (i = 0; i < label_chemical->total; i++) fprintf (global.outfile, "%6s", ""); fprintf (global.outfile, " | LIGAND\n"); for (i = 0; i < label_chemical->total; i++) { fprintf (global.outfile, " | "); for (j = 0; j < label_chemical->total; j++) { sprintf (value, "%6.2f", (*table)[i][j]); if (value[5] == '0') { value[5] = ' '; if (value[4] == '0') { value[4] = ' '; value[3] = ' '; if (atoi (value) == 0) strcpy (value, ""); } } fprintf (global.outfile, "%6s", value); } fprintf (global.outfile, " | %s\n", label_chemical->member[i].name); } fprintf (global.outfile, " |_"); for (i = 0; i < label_chemical->total; i++) fprintf (global.outfile, "%6s", "______"); fprintf (global.outfile, "_|\n\n"); for (i = 0, continue_loop = TRUE; (i < sizeof (STRING20)) && continue_loop; i++) { if (receptor_axis[i]) { fprintf (global.outfile, " %c", receptor_axis[i]); continue_loop = TRUE; } else fprintf (global.outfile, "%3s", ""); for (j = continue_loop = 0; j < label_chemical->total; j++) { if (label_chemical->member[j].name[i]) { fprintf (global.outfile, " %c ", label_chemical->member[j].name[i]); continue_loop = TRUE; } else fprintf (global.outfile, "%6s", ""); } fprintf (global.outfile, "\n"); } fprintf (global.outfile, "\n\n");}/* ============================================================= */void free_table( LABEL_CHEMICAL *label_chemical, float ***table){ int i; for (i = 0; i < label_chemical->total; i++) efree ((void **) &(*table)[i]); efree ((void **) table);}/* //////////////////////////////////////////////////////////////////// */int assign_chemical_labels( LABEL_CHEMICAL *label_chemical, MOLECULE *molecule){ int i, j, k; if (!label_chemical->init_flag) get_chemical_labels (label_chemical); molecule->info.assign_chem = TRUE; for (i = 0; i < molecule->total.atoms; i++) molecule->atom[i].chem_id = 0; for (i = 0; i < molecule->total.atoms; i++) for (j = 1; j < label_chemical->total; j++) for (k = 0; k < label_chemical->member[j].definition_total; k++) if (check_atom (molecule, i, &label_chemical->member[j].definition[k])) molecule->atom[i].chem_id = j;/** Print out chemical label assignments* 10/95 te*/ if (global.output_volume == 'v') { fprintf (global.outfile, "____Chemical_Assignments____\n"); fprintf (global.outfile, "%s:\n\n", molecule->info.name); for (i = 0; i < molecule->total.atoms; i++) fprintf (global.outfile, "%6d %4s %5s %-20s\n", i + 1, molecule->atom[i].name, molecule->atom[i].type, label_chemical->member[molecule->atom[i].chem_id].name); fprintf (global.outfile, "\n\n"); } return TRUE;} /* //////////////////////////////////////////////////////////////// */void read_chemical_labels( LABEL_CHEMICAL *label_chemical, MOLECULE *molecule, FILE_NAME molecule_file_name, FILE *molecule_file){ int i, j; long file_position; int label_count, label_match, *label_conversion = NULL; char buff[200];/** Record current file position* 2/96 te*/ file_position = ftell (molecule_file); rewind (molecule_file);/** Read in header line of file* 6/95 te*/ if (!fgets (buff, 199, molecule_file)) exit (fprintf (global.outfile, "ERROR read_chemical_labels: No data in SPH file %s\n", molecule_file_name)); if (!strncmp (buff, "cluster", 7)) exit (fprintf (global.outfile, "ERROR read_chemical_labels: No chemical labels are in SPH file %s\n", molecule_file_name));/** Construct list to convert chemical labels read here to proper* chem_id values* 6/95 te*/ ecalloc ( (void **) &label_conversion, label_chemical->total, sizeof (int), "chemical label conversion list", global.outfile ); for (i = 1; i < label_chemical->total; i++) label_conversion[i] = -1; if (!fgets (buff, 199, molecule_file)) exit (fprintf (global.outfile, "ERROR read_chemical_labels: No chemical labels are in SPH file %s\n", molecule_file_name)); label_count = 0; while (strncmp (buff, "cluster", 7)) { label_match = FALSE; for (i = 0; i < label_chemical->total; i++) if (!strncmp (buff, label_chemical->member[i].name, strlen (label_chemical->member[i].name))) { label_conversion[i] = ++label_count; label_match = TRUE; break; } if (!label_match) exit (fprintf (global.outfile, "ERROR read_chemical_labels: No definition for %s in SPH file %s\n", buff, molecule_file_name)); if (!fgets (buff, 199, molecule_file)) exit (fprintf (global.outfile, "ERROR read_chemical_labels: Insufficient labels in SPH file %s\n", molecule_file_name)); } for (i = 0; i < molecule->total.atoms; i++) {/** Convert chemical label integer* 6/95 te*/ if (label_chemical->total && label_conversion) { if (molecule->atom[i].chem_id > label_count + 1) exit (fprintf (global.outfile, "ERROR read_chemical_labels: " "Improper chemical label for entry %s in %s\n", molecule->atom[i].name, molecule_file_name)); for (j = 0; j < label_chemical->total; j++) if (label_conversion[j] == molecule->atom[i].chem_id) { molecule->atom[i].chem_id = j; break; } } } efree ((void **) &label_conversion);/** Return to original file position* 2/96 te*/ fseek (molecule_file, file_position, SEEK_SET);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?