gint reaxmd_output_coords_read(gpointer import)
{
gchar *fullname, *line;
FILE *fp;

#if DEBUG_READ_DCD
printf("Adding [dcd] data to file: %s\n", import_fullpath(import));
#endif

fullname = parse_extension_set(import_fullpath(import), "dcd");
if (!g_file_test(fullname, G_FILE_TEST_EXISTS))
  {
  gui_text_show(ERROR, "Failed to find associated .dcd file.\n");
  g_free(fullname);
  return(1);
  }

// TODO - if existing frames - assume replace mode
// otherwise create new frame at each step

/* NB: binary file data */
fp = fopen(fullname, "rb");
while (fp)
  {
  line = file_read_line(fp);
  if (!line)
    break;

  g_free(line);
  }

return(1);
}
Beispiel #2
0
void gui_animate_movie_type_change(GtkWidget *type, gpointer name)
{
gchar *movie;
const gchar *text, *ext;

text = gtk_entry_get_text(GTK_ENTRY(type));

//printf("type = %s\n", text);

if (g_strncasecmp(text, "avi", 3) == 0)
  ext = "avi";
if (g_strncasecmp(text, "flv", 3) == 0)
  ext = "flv";
if (g_strncasecmp(text, "mp4", 3) == 0)
  ext = "mp4";
if (g_strncasecmp(text, "mpg", 3) == 0)
  ext = "mpg";

text = gtk_entry_get_text(GTK_ENTRY(name));

movie = parse_extension_set(text, ext);

//printf("movie = %s\n", movie);

gtk_entry_set_text(GTK_ENTRY(name), movie);

g_free(movie);
}
gint write_gromacs(gchar *filename, struct model_pak *model)
{
gchar *temp;

temp = parse_extension_set(filename, "top");

write_gromacs_gro(filename, model);
write_gromacs_top(temp, model);

g_free(temp);

return(0);
}
gint reaxmd_output_import(gpointer import)
{
gint status=0;
gchar *fullname_model, *fullname_energy, *fullname_coords, *fullname_velos;
struct model_pak *model=NULL;
FILE *fp_m, *fp_c, *fp_e, *fp_v;

if (!import)
  return(1);

fullname_model = parse_extension_set(import_fullpath(import), "pdb");
fullname_coords = parse_extension_set(import_fullpath(import), "dcd");
fullname_energy = parse_extension_set(import_fullpath(import), "erx");
fullname_velos = parse_extension_set(import_fullpath(import), "vrx");

fp_m = fopen(fullname_model, "rt");
fp_e = fopen(fullname_energy, "rt");
fp_c = fopen(fullname_coords, "rb");
fp_v = fopen(fullname_velos, "rb");

// bare minimum parse
if (fp_m)
  {
  model = model_new();
  read_pdb_block(fp_m, model);
  fclose(fp_m);
  }
else
  {
  status = 1;
  gui_text_show(ERROR, "Failed to open reference PDB model for ReaxMD.\n");
  goto reaxmd_output_import_cleanup;
  }

// main extra data (coords)
if (fp_c)
  {
  reaxmd_parse_coordinates(fp_c, model);
  fclose(fp_c);
  }

// optional extra data (velocities)
if (fp_v)
  {
  reaxmd_parse_velocities(fp_v, model);
  fclose(fp_v);
  }

// optional extra data (energy, temp, etc)
// CURRENT - only read corresponding values for which we have coord frames
if (fp_e)
  {
  reaxmd_parse_properties(fp_e, model, import);
  fclose(fp_e);
  }

// init
if (model)
  import_object_add(IMPORT_MODEL, model, import);

import_init(import);

#if DEBUG_REAXMD_OUTPUT
animate_debug(model);
#endif

// done
reaxmd_output_import_cleanup:

g_free(fullname_model);
g_free(fullname_coords);
g_free(fullname_energy);
g_free(fullname_velos);

return(status);
}
// no coords - just control data for the run
// coords - .pdb file
// topology - .frx file
gint reaxmd_input_import(gpointer import)
{
gint *symbols, num_symbols, unknown;
gchar *line, *fullname_model;
gchar *filename, *filepath;
gpointer scan, config;
GString *unparsed;
struct reaxmd_pak *reaxmd;
struct model_pak *model;
FILE *fp;

scan = scan_new(import_fullpath(import));
if (!scan)
  return(1);

/* populate symbol table */
reaxmd_symbols_init(scan);

config = config_new(REAXMD, NULL);
reaxmd = config_data(config);

unparsed = g_string_new(NULL);

while (!scan_complete(scan))
  {
  symbols = scan_get_symbols(scan, &num_symbols);
  if (num_symbols)
    {
    unknown = FALSE;
/* process first recognized symbol */
    switch (symbols[0])
      {
      case REAXMD_NSTEPS:
        reaxmd->total_steps = parse_nth_token_dup(1, scan_cur_line(scan));
        break;

      case REAXMD_TIMESTEP:
      case REAXMD_TEMPERATURE:
      case REAXMD_THERMOSTAT:
      case REAXMD_BAROSTAT:
      case REAXMD_CUTOFF:
      case REAXMD_UPDATE:
      case REAXMD_NWRITE:
      case REAXMD_GRID:
        break;

      case REAXMD_PLUMED_FILE:
        filename = parse_nth_token_dup(1, scan_cur_line(scan));
        filepath = g_build_filename(import_path(import), filename, NULL);
//printf("Looking for: %s\n", filepath);
        if (g_file_test(filepath, G_FILE_TEST_EXISTS))
          project_job_file_append(NULL, filepath, sysenv.workspace);
        else
          gui_text_show(ERROR, "REAXMD plumed file was not found!\n"); 
        g_free(filename);
        g_free(filepath);
        break;

      default:
        unknown = TRUE;
      }
    g_free(symbols);
    }
  else
    unknown=TRUE;

  if (unknown)
    {
    line = scan_cur_line(scan);
    if (line)
      g_string_append(unparsed, line);
    }
  }

config_unparsed_set(g_string_free(unparsed, FALSE), config);
/* CURRENT - free this, until we add a GUI */
//import_object_add(IMPORT_CONFIG, config, import);
config_free(config);

/* done irx parse */
scan_free(scan);

/* NEW - attempt to load reference coordinates */
fullname_model = parse_extension_set(import_fullpath(import), "pdb");
fp = fopen(fullname_model, "rt");
if (fp)
  {
  model = model_new();
  read_pdb_block(fp, model);
  fclose(fp);
  import_object_add(IMPORT_MODEL, model, import);
  }
else
  {
  gui_text_show(WARNING, "Failed to open reference PDB model for ReaxMD.\n");
  }
g_free(fullname_model);

/* init */
import_init(import);

return(0);
}