clustal-omega-1.2.4/src/clustal-omega.c
/**
 * @brief Create a HHM file from aligned sequences
 *
 * @warning Should be eliminated in the future 
 * as building routine should not create intermediate files
 *
 * @param[in] prMSeq
 * Aligned mseq_t
 * @param[in] pcHMMOut
 * HMM output file name
 *
 * @return Non-zero on error
 *
 */
@brief Create a HHM file from aligned sequences

@warning Should be eliminated in the future
as building routine should not create intermediate files

@param[in] prMSeq
Aligned mseq_t
@param[in] pcHMMOut
HMM output file name

@return Non-zero on error
@brief Create a HHM file from aligned sequences @warning Should be eliminated in the future as building routine should not create intermediate files @param [ in ] prMSeq Aligned mseq_t @param [ in ] pcHMMOut HMM output file name @return Non - zero on error
int
AlnToHHMFile(mseq_t *prMSeq, char *pcHMMOut)
{
    char *tmp_aln = NULL;
    int retcode = OK;
    assert(NULL!=prMSeq);
    assert(NULL!=pcHMMOut);
    if (FALSE == prMSeq->aligned) {
        Log(&rLog, LOG_ERROR, "Sequences need to be aligned to create an HMM");
        return FAILURE;
    }
    tmp_aln = CkStrdup("/tmp/clustalo_tmpaln_XXXXXX");
    if (NULL == mktemp(tmp_aln)) {
        Log(&rLog, LOG_ERROR, "Could not create temporary alignment filename");
        retcode = FAILURE;
        goto cleanup_and_return;
    }
#define LINE_WRAP 60
    if (WriteAlignment(prMSeq, tmp_aln, MSAFILE_A2M, LINE_WRAP, FALSE)) {
        Log(&rLog, LOG_ERROR, "Could not save alignment to %s", tmp_aln);
        retcode = FAILURE;
        goto cleanup_and_return;
    }
    if (HHMake_Wrapper(tmp_aln, pcHMMOut)){
        Log(&rLog, LOG_ERROR, "Could not convert alignment %s into HHM", tmp_aln);
        retcode = FAILURE;
        goto cleanup_and_return;
    }
 cleanup_and_return:
    if (NULL != tmp_aln) {
        if (FileExists(tmp_aln)) {
            if (remove(tmp_aln)) {
                Log(&rLog, LOG_WARN, "Removing %s failed. Continuing anyway", tmp_aln);
            }
        }
        CKFREE(tmp_aln);
    }
    return retcode; 
}
int AlnToHHMFile ( mseq_t * prMSeq , char * pcHMMOut ) { char * tmp_aln = NULL ; int retcode = OK ; assert ( NULL != prMSeq ) ; assert ( NULL != pcHMMOut ) ; if ( FALSE == prMSeq -> aligned ) { Log ( & rLog , LOG_ERROR , " " ) ; return FAILURE ; } tmp_aln = CkStrdup ( " " ) ; if ( NULL == mktemp ( tmp_aln ) ) { Log ( & rLog , LOG_ERROR , " " ) ; retcode = FAILURE ; goto cleanup_and_return ; } #define LINE_WRAP  60
 if ( WriteAlignment ( prMSeq , tmp_aln , MSAFILE_A2M , LINE_WRAP , FALSE ) ) { Log ( & rLog , LOG_ERROR , " " , tmp_aln ) ; retcode = FAILURE ; goto cleanup_and_return ; } if ( HHMake_Wrapper ( tmp_aln , pcHMMOut ) ) { Log ( & rLog , LOG_ERROR , " " , tmp_aln ) ; retcode = FAILURE ; goto cleanup_and_return ; } cleanup_and_return : if ( NULL != tmp_aln ) { if ( FileExists ( tmp_aln ) ) { if ( remove ( tmp_aln ) ) { Log ( & rLog , LOG_WARN , " " , tmp_aln ) ; } } CKFREE ( tmp_aln ) ; } return retcode ; }
@brief Create a HHM file from aligned sequences
@brief Create a HHM file from aligned sequences
/* Convert alignment to a2m, and call hhmake
     *
     * can't be static templates, or mktemp fails (at least on os x
     * (with a bus error))
     * 
     * gcc says we should use mkstemp to avoid race conditions, 
     * but that returns a file descriptor, which is of no use to 
     * us  
     */ /* NOTE: the following won't work on windows: missing /tmp/ */