Esempio n. 1
0
PSIMatrix*
PSIMatrixNew(Uint4 query_length, Uint4 alphabet_size)
{
    PSIMatrix* retval = NULL;

    retval = (PSIMatrix*) malloc(sizeof(PSIMatrix));
    if ( !retval ) {
        return NULL;
    }
    retval->ncols = query_length;
    retval->nrows = alphabet_size;

    retval->pssm = (int**) _PSIAllocateMatrix(query_length, alphabet_size,
                                              sizeof(int));
    if ( !(retval->pssm) ) {
        return PSIMatrixFree(retval);
    }

    retval->lambda = 0.0;
    retval->kappa = 0.0;
    retval->h = 0.0;
    retval->ung_lambda = 0.0;
    retval->ung_kappa = 0.0;
    retval->ung_h = 0.0;

    return retval;
}
Esempio n. 2
0
/** Convenience function to deallocate data structures allocated in
 * PSICreatePssmFromFrequencyRatios
 * @param pssm PSSM and statistical information [in|out]
 * @param internal_pssm PSSM being computed [in]
 * @param std_prob array containing the standard background residue 
 * probabilities [in]
 */
static void
s_PSICreatePssmFromFrequencyRatiosCleanUp(PSIMatrix** pssm,
                                          _PSIInternalPssmData* internal_pssm,
                                          double* std_prob)
{
    if (pssm) {
        *pssm = PSIMatrixFree(*pssm);
    }
    _PSIInternalPssmDataFree(internal_pssm);
    sfree(std_prob);
}
Esempio n. 3
0
/**
 * Read a checkpoint file and set the necessary structures in a
 * BlastScoreBlk: the psi_matrix, kbp_psi[0], and kbp_gap_psi[0].
 *
 * @param sbp              a BlastScoreBlk to receive a PSSM [in/out]
 * @param query            query sequence data
 * @param psi_matrix_file  checkpoint file to read
 * @pcore_msg              a pointer to receive error and warning messages
 */
static int
s_SetupScoreBlkPssmFromChkpt(BlastScoreBlk * sbp,
                             BLAST_SequenceBlk * query,
                             Blast_PsiCheckpointLoc * psi_checkpoint,
                             Blast_Message* *pcore_msg)
{
    int status = 0;
    /* An intermediate representation of the PSSM data that is used
       in PSIBlast routines */
    PSIMatrix * pssm = NULL;
    /* The actual PSSM that is saved in the BlastScoreBlk */
    SPsiBlastScoreMatrix * psi_matrix = NULL;
    size_t i, j;

    psi_matrix = SPsiBlastScoreMatrixNew(query->length);
    if (!psi_matrix) {
        ErrPostEx(SEV_FATAL, 1, 0,
            "Out-of-memory: cannot allocate a PSSM of length %d.\n",
            query->length);
        status = -1;
        goto error_return;
    }
    status = Blast_PosReadCheckpoint(psi_matrix->freq_ratios,
                                     query->length, query->sequence,
                                     psi_checkpoint,
                                     pcore_msg);
    if (status != 0) {
        goto error_return;
    }
    Blast_KarlinBlkCopy(psi_matrix->kbp, sbp->kbp_gap_std[0]);
    status = PSICreatePssmFromFrequencyRatios(query->sequence,
                                              query->length, sbp,
                                              psi_matrix->freq_ratios,
                                              kPSSM_NoImpalaScaling,
                                              &pssm);
    if (0 != status) {
        goto error_return;
    }
    for (i = 0;  i < psi_matrix->pssm->ncols;  i++) {
        for (j = 0;  j < psi_matrix->pssm->nrows;  j++) {
            psi_matrix->pssm->data[i][j] = pssm->pssm[i][j];
        }
    }
    PSIMatrixFree(pssm);
    sbp->psi_matrix = psi_matrix;
    return 0;
error_return:
    if (psi_matrix)
        SPsiBlastScoreMatrixFree(psi_matrix);
    return status;
}
Esempio n. 4
0
static void
s_PSICreatePssmCleanUp(PSIMatrix** pssm,
                       _PSIPackedMsa* packed_msa,
                       _PSIMsa* msa,
                       _PSIAlignedBlock* aligned_block,
                       _PSISequenceWeights* seq_weights,
                       _PSIInternalPssmData* internal_pssm)
{
    if (pssm) {
        *pssm = PSIMatrixFree(*pssm);
    }
    _PSIPackedMsaFree(packed_msa);
    _PSIMsaFree(msa);
    _PSIAlignedBlockFree(aligned_block);
    _PSISequenceWeightsFree(seq_weights);
    _PSIInternalPssmDataFree(internal_pssm);
}