/****************************************************************************** * This function scores a sequence database using mhmmscan *****************************************************************************/ void run_mhmmscan( MCAST_OPTIONS_T *options, char *hmm_filename, char *seq_filename, char *scores_filename ) { if (verbosity >= NORMAL_VERBOSE) { fprintf(stderr, "%s", "Creating HMM from motif file.\n"); } // Build the command line for mhmmscan const char *bin_dir = get_meme_bin_dir(); char *cmd; cmd = build_cmd( "mhmmscan", "%s/mhmmscan %s %s %s --fancy --allow-weak-motifs %s --p-thresh %s " "--max-gap %s --e-thresh %s --eg-cost 1 --pseudo-weight %s %s " "%s %s > %s", bin_dir, options->bg_filename != NULL ? "--bg-file" : "", options->bg_filename != NULL ? options->bg_filename : "", options->text_only ? "--text" : "", options->use_synth ? "--synth" : "", options->p_thresh, options->max_gap, options->e_thresh, options->pseudo_weight, options->quiet ? "--quiet" : "", hmm_filename, seq_filename, scores_filename ); // Execute mhmmscan if (verbosity >= NORMAL_VERBOSE) { fprintf(stderr, "Executing %s\n", cmd); } int status = system(cmd); // Check for interrupts if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGINT || WTERMSIG(status) == SIGQUIT)) { die("Interrupted while running mhmmscan"); } if (status == -1) { // Unable to start mhmmscan perror("Error starting mhmmscan command"); die("Unable to start mhmmscan command (%s)", cmd); } // Check result of running mhmmscan int result = WEXITSTATUS(status); if (result != 0) { die("mhmmscan failed with exit status %d, command run was: %s", result, cmd); } free(cmd); }
/****************************************************************************** * This function builds a star topology HMM from a MEME format motif file. * The HMM is stored in a text file in the output directory. *****************************************************************************/ void run_mhmm( char *motif_filename, char *hmm_filename ) { if (verbosity >= NORMAL_VERBOSE) { fprintf(stderr, "%s", "Creating HMM from motif file.\n"); } // Build the command line for mhmm const char *bin_dir = get_meme_bin_dir(); char *cmd; cmd = build_cmd( "mhmm", "%s/mhmm --type star --keep-unused --verbosity %d %s > %s", bin_dir, verbosity, motif_filename, hmm_filename ); // Execute mhmm if (verbosity >= NORMAL_VERBOSE) { fprintf(stderr, "Executing %s\n", cmd); } int status = system(cmd); // Check for interrupts if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGINT || WTERMSIG(status) == SIGQUIT)) { die("Interrupted while running mhmm"); } if (status == -1) { // Unable to start mhmm perror("Error starting mhmm command"); die("Unable to start mhmm command (%s)", cmd); } // Check result of running mhmm int result = WEXITSTATUS(status); if (result != 0) { die("mhmm failed with exit status %d, command run was: %s", result, cmd); } free(cmd); }
int main(int argc, char **argv) { data d; glam2_aln *alns; int r; prog_name = "glam2"; /* for error messages */ getargs(&d.a, argc, argv); init(&d); fputs("GLAM2: Gapped Local Alignment of Motifs\nVersion " #include "glam2_version.h" "\n\n", d.out); printargs(d.out, argc, argv); print_misc_info(d.out, &d); putc('\n', d.out); XMALLOC(alns, d.a.runs); for (r = 0; r < d.a.runs; ++r) { glam2_aln *aln = &alns[r]; if (!d.a.quiet) { fprintf(stderr, "Run %d... ", r+1); fflush(stderr); } aln_init(aln, d.seqs.seqnum, d.a.max_width, d.alph.size); d.sm.underflow_flag = 1; /* do we care about underflow in start_aln? */ start_aln(aln, &d); optimise_aln(aln, &d); if (d.sm.underflow_flag < (d.a.algorithm == 2 ? DBL_EPSILON : DBL_MIN)) fprintf(stderr, "%s: accuracy loss due to numeric underflow (%g)\nIf the alignment looks suspect, try rerunning with higher -u, or maybe lower -b\n", prog_name, d.sm.underflow_flag); if (d.a.profile) print_aln_info(d.out, aln, &d); } if (!d.a.quiet) putc('\n', stderr); SORT(alns, d.a.runs, aln_cmp); if (!d.a.profile) print_alns(d.out, alns, &d); xfclose(d.out); // close text output file // Create the HTML output and MEME format output char *glam2html, *glam2psfm, *command; int command_length, command_ret; // create the paths to the programs glam2html = make_path_to_file(get_meme_bin_dir(), "glam2html"); glam2psfm = make_path_to_file(get_meme_bin_dir(), "glam2psfm"); // allocate memory for the command command_length = strlen(glam2html) + strlen(d.txt_filename) + strlen(d.html_filename) + 50; command = xmalloc(command_length); // run glam2html sprintf(command, "%s < %s > %s", glam2html, d.txt_filename, d.html_filename); if ((command_ret = system(command)) != 0) { report_external_failure("glam2html", command_ret); fprintf(stderr, "Warning: failed to convert output to HTML!\n"); } // run glam2psfm sprintf(command, "%s < %s > %s", glam2psfm, d.txt_filename, d.psfm_filename); if ((command_ret = system(command)) != 0) { report_external_failure("glam2psfm", command_ret); fprintf(stderr, "Warning: failed to convert output to MEME format motif!\n"); } free(command); free(glam2psfm); free(glam2html); return 0; }