/* Function: p7_banner() * Synopsis: print standard HMMER application output header * Incept: SRE, Wed May 23 10:45:53 2007 [Janelia] * * Purpose: Print the standard HMMER command line application banner * to <fp>, constructing it from <progname> (the name of the * program) and a short one-line description <banner>. * For example, * <p7_banner(stdout, "hmmsim", "collect profile HMM score distributions");> * might result in: * * \begin{cchunk} * # hmmsim :: collect profile HMM score distributions * # HMMER 3.0 (May 2007) * # Copyright (C) 2004-2007 HHMI Janelia Farm Research Campus * # Freely licensed under the Janelia Software License. * # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * \end{cchunk} * * <progname> would typically be an application's * <argv[0]>, rather than a fixed string. This allows the * program to be renamed, or called under different names * via symlinks. Any path in the <progname> is discarded; * for instance, if <progname> is "/usr/local/bin/hmmsim", * "hmmsim" is used as the program name. * * Note: * Needs to pick up preprocessor #define's from p7_config.h, * as set by ./configure: * * symbol example * ------ ---------------- * HMMER_VERSION "3.0" * HMMER_DATE "May 2007" * HMMER_COPYRIGHT "Copyright (C) 2004-2007 HHMI Janelia Farm Research Campus" * HMMER_LICENSE "Freely licensed under the Janelia Software License." * * Returns: (void) */ void p7_banner(FILE *fp, char *progname, char *banner) { char *appname = NULL; if (esl_FileTail(progname, FALSE, &appname) != eslOK) appname = progname; fprintf(fp, "# %s :: %s\n", appname, banner); fprintf(fp, "# HMMER %s (%s); %s\n", HMMER_VERSION, HMMER_DATE, HMMER_URL); fprintf(fp, "# %s\n", HMMER_COPYRIGHT); fprintf(fp, "# %s\n", HMMER_LICENSE); fprintf(fp, "# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"); if (appname != NULL) free(appname); return; }
static int output_header(FM_METADATA *meta, FILE *ofp, const ESL_GETOPTS *go, char *fmfile, char *qfile) { char *alph; char *appname = NULL; int status; if (meta->alph_type == fm_DNA) alph = "dna"; else if (meta->alph_type == fm_AMINO) alph = "amino"; if ((status = esl_FileTail(go->argv[0], FALSE, &appname)) != eslOK) return status; if (fprintf(ofp, "# %s :: %s\n", appname, banner) < 0) ESL_XEXCEPTION_SYS(eslEWRITE, "write failed"); if (fprintf(ofp, "# %s\n", EASEL_COPYRIGHT) < 0) ESL_XEXCEPTION_SYS(eslEWRITE, "write failed"); if (fprintf(ofp, "# %s\n", EASEL_LICENSE) < 0) ESL_XEXCEPTION_SYS(eslEWRITE, "write failed"); if (fprintf(ofp, "# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n") < 0) ESL_XEXCEPTION_SYS(eslEWRITE, "write failed"); if (fprintf(ofp, "# input binary-formatted HMMER database: %s\n", fmfile) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed"); if (fprintf(ofp, "# input file of query sequences: %s\n", qfile) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed"); if (esl_opt_IsUsed(go, "--out")) { char *outfile = esl_opt_GetString(go, "--out"); if (fprintf(ofp, "# output file containing list of hits: %s\n", (esl_strcmp(outfile, "-") == 0 ? "stdout" : outfile)) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed"); } if (esl_opt_IsUsed(go, "--count_only") && fprintf(ofp, "# output only counts, not hit locations\n") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed"); if (fprintf(ofp, "# alphabet : %s\n", alph) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed"); if (fprintf(ofp, "# bin_length : %d\n", meta->freq_cnt_b) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed"); if (fprintf(ofp, "# suffix array sample rate: %d\n", meta->freq_SA) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed"); if (fprintf(ofp, "# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed"); if (appname) free(appname); return eslOK; ERROR: if (appname) free(appname); return status; }
/* set_msa_name() * Make sure the alignment has a name; this name will * then be transferred to the model. * * We can only do this for a single alignment in a file. For multi-MSA * files, each MSA is required to have a name already. * * Priority is: * 1. Use -n <name> if set, overriding any name the alignment might already have. * 2. Use alignment's existing name, if non-NULL. * 3. Make a name, from alignment file name without path and without filename extension * (e.g. "/usr/foo/globins.slx" gets named "globins") * If none of these succeeds, return <eslEINVAL>. * * If a multiple MSA database (e.g. Stockholm/Pfam), and we encounter * an MSA that doesn't already have a name, return <eslEINVAL> if nali > 1. * (We don't know we're in a multiple MSA database until we're on the second * alignment.) * * If we're in MPI mode, we assume we're in a multiple MSA database, * even on the first alignment. * * Because we can't tell whether we've got more than one * alignment 'til we're on the second one, these fatal errors * only happen after the first HMM has already been built. * Oh well. */ static int set_msa_name(struct cfg_s *cfg, char *errbuf, ESL_MSA *msa) { char *name = NULL; int status; if (cfg->do_mpi == FALSE && cfg->nali == 1) /* first (only?) HMM in file: */ { if (cfg->hmmName != NULL) { if ((status = esl_msa_SetName(msa, cfg->hmmName)) != eslOK) return status; } else if (msa->name != NULL) { cfg->nnamed++; } else if (! cfg->afp->do_stdin) { if ((status = esl_FileTail(cfg->afp->fname, TRUE, &name)) != eslOK) return status; /* TRUE=nosuffix */ if ((status = esl_msa_SetName(msa, name)) != eslOK) return status; free(name); } else ESL_FAIL(eslEINVAL, errbuf, "Failed to set model name: msa has no name, no msa filename, and no -n"); } else { if (cfg->hmmName != NULL) ESL_FAIL(eslEINVAL, errbuf, "Oops. Wait. You can't use -n with an alignment database."); else if (msa->name != NULL) cfg->nnamed++; else ESL_FAIL(eslEINVAL, errbuf, "Oops. Wait. I need name annotation on each alignment in a multi MSA file; failed on #%d", cfg->nali+1); /* special kind of failure: the *first* alignment didn't have a name, and we used the filename to * construct one; now that we see a second alignment, we realize this was a boo-boo*/ if (cfg->nnamed != cfg->nali) ESL_FAIL(eslEINVAL, errbuf, "Oops. Wait. I need name annotation on each alignment in a multi MSA file; first MSA didn't have one"); } return eslOK; }