コード例 #1
0
/* ---------------- aa_strct_2_prob_vec  ----------------------
 * This calculates probabilities, using both sequence and structure
 * terms.
 */
struct prob_vec *
aa_strct_2_prob_vec (struct coord *structure,
                     const struct aa_strct_clssfcn *cmodel, const int norm)
{
    const char *this_sub = "aa_strct_2_prob_vec";
    struct prob_vec *pvec;
    struct seq *seqtmp;
    static int debug_n = 1;
    if (debug_n) {
        debug_n = 0;
        err_printf (this_sub, "%s called in new version\n", this_sub);
    }
    if (!structure) {
        err_printf (this_sub, "No Structure Input\n");
        return NULL;
    }
    if (!cmodel || !cmodel->strct || !cmodel->log_pp) {
        err_printf (this_sub, "No Classification Input\n");
        return NULL;
    }
    seqtmp = coord_get_seq (structure);
    pvec= seq_strct_2_prob_vec (structure, seqtmp, 0,
                                 structure->size, cmodel, norm);
    seq_destroy (seqtmp);
    return pvec;
}
コード例 #2
0
ファイル: sequence.c プロジェクト: cigolabs/flux-core
static int handle_seq_destroy (seqhash_t *s, JSON in, JSON *outp)
{
    const char *name;
    if (!Jget_str (in, "name", &name)) {
        errno = EPROTO;
        return (-1);
    }
    if (seq_destroy (s, name) < 0)
        return (-1);
    *outp = Jnew ();
    Jadd_str (*outp, "name", name);
    Jadd_bool (*outp, "destroyed", true);
    return (0);
}
コード例 #3
0
ファイル: test-0124.c プロジェクト: kdudka/predator
int main()
{
    struct list *data = NULL;
    seq_read(&data);
    seq_write(data);
    __VERIFIER_plot(NULL);

    // NOTE: you may mix seq_insert/seq_sort as you like, we'll take care of it
    seq_sort(&data);
    seq_write(data);
    __VERIFIER_plot(NULL);

    seq_destroy(data);
    __VERIFIER_plot(NULL);

    return 0;
}
コード例 #4
0
ファイル: bipartite_scan.c プロジェクト: alexplong/biopieces
void run_scan( int argc, char *argv[] )
{
    /* Martin A. Hansen, September 2008 */

    /* For each file in argv scan the file for */
    /* bipartite motifs and output the motifs */
    /* and their count. */

    char      *file        = NULL;
    int        i           = 0;
    seq_entry *entry       = NULL;
    uint      *count_array = NULL;
//    size_t    new_nmemb    = 0;

    count_array = count_array_new( COUNT_ARRAY_NMEMB );

    entry = seq_new( MAX_SEQ_NAME, MAX_SEQ );

    for ( i = 1; i < argc; i++ )
    {
        file = argv[ i ];

        fprintf( stderr, "Scanning file: %s\n", file );
        scan_file( file, entry, count_array );
        fprintf( stderr, "done.\n" );
    }

//    fprintf( stderr, "Printing motifs: ... " );
//    count_array_print( count_array, COUNT_ARRAY_NMEMB, CUTOFF );
//    fprintf( stderr, "done.\n" );

    file = argv[ 1 ];

    fprintf( stderr, "Rescanning file: %s\n", file );
    rescan_file( file, entry, count_array, CUTOFF );
    fprintf( stderr, "done.\n" );

    seq_destroy( entry );

    mem_free( &count_array );
}
コード例 #5
0
/* ---------------- seq_strct_2_duplicated_prob_vec  -----------------------
 * Duplikate the pvec while structure estimation and also duplicate the sequence,
 * each n-times.
 * return:
 * 		struct prob_vec *pvec
 * Notice: not used, but who knows if it will became useful one day !
 * (Martin May, 2007)
 */
struct prob_vec *
strct_2_duplicated_prob_vec (struct coord *structure, const struct seq *seq,
                      const struct seqprof *sp, const size_t size,
                      const struct aa_strct_clssfcn *cmodel, const size_t n_duplications)
{
    size_t i, j;
    float *fragment;
    struct prob_vec *pvec;
    float **aa_prob;
    struct aa_clssfcn *aa_class;
    const size_t n_pvec = size - cmodel->n_att + 1;

    if ((pvec = new_pvec (cmodel->n_att, n_duplications * size , n_duplications * n_pvec,
                          cmodel->strct->n_class))!= NULL) {
        for (i = 0; i < (n_duplications * n_pvec); i++)          /* Initialize mship */
            for (j = 0; j < cmodel->strct->n_class; j++)
                pvec->mship[i][j] = cmodel->strct->class_weight[j];

        if (structure) {                           /* Structure membership */
            for (i = 0; i < n_pvec; i++){           /* for every fragment...*/
                     /* twice for every fragment on position  i as on i + size */
                     fragment = getFragment (i , cmodel->n_att, structure);
                     for (j = 0; j < n_duplications; j++){
                        if (computeMembershipStrct(pvec->mship[ i + j * n_pvec], fragment,
		                               cmodel->strct) == NULL) {
                        prob_vec_destroy (pvec);
                        return NULL;
                    }
                }
            }
            free_if_not_null (fragment);
        }

        if (sp || seq) {                /* Sequence or profile membership */
            aa_prob = f_matrix (n_duplications * n_pvec,  cmodel->strct->n_class);
            aa_class = E_MALLOC (sizeof (struct aa_clssfcn));
            aa_class->n_class = cmodel->strct->n_class;
            aa_class->n_att = cmodel->n_att;
            aa_class->log_pp = cmodel->log_pp;
            aa_class->class_wt = cmodel->strct->class_weight;
            if (seq){
                struct seq *s = seq_duplicate ( seq , n_duplications );
                if (computeMembershipAA (aa_prob, s, aa_class)
                    == EXIT_FAILURE) {
                    prob_vec_destroy (pvec);
                    return NULL;
                }
                seq_destroy (s);
            } else if (sp) {
                if (computeMembershipAAProf (aa_prob, sp, aa_class)
                    == EXIT_FAILURE) {
                    prob_vec_destroy (pvec);
                    return NULL;
                }
            }
            free (aa_class);
            for (i = 0; i < n_duplications * n_pvec; i++)
                for (j = 0; j < cmodel->strct->n_class; j++)
                    pvec->mship[i][j] *= aa_prob[i][j];
            kill_f_matrix (aa_prob);
        }

        for (i = 0; i < (n_duplications * n_pvec); i++){
            double sum = 0.0;
            for (j = 0; j < cmodel->strct->n_class; j++)
                sum += pvec->mship[i][j];
            for (j = 0; j < cmodel->strct->n_class; j++)
                pvec->mship[i][j] /= sum;
        }
        pvec->norm_type = PVEC_TRUE_PROB;
    }
    return pvec;
}
コード例 #6
0
/* ---------------- seq_strct_2_prob_vec  -----------------------
 * This calculates probabilities for using combinations of
 * sequence and structure, sequence profile and structure,
 * sequence only, sequence profile only, and structure only.
 */
static struct prob_vec *
seq_strct_2_prob_vec (struct coord *structure, const struct seq *seq,
                      const struct seqprof *sp, const size_t size,
                      const struct aa_strct_clssfcn *cmodel,
                      const enum yes_no norm)
{
    size_t i, j, compnd_len;
    float *fragment;
    struct prob_vec *pvec;
    float **aa_prob;
    struct aa_clssfcn *aa_class;
    const size_t n_pvec = size - cmodel->n_att + 1;

    if ((pvec = new_pvec (cmodel->n_att, size,n_pvec,
                          cmodel->strct->n_class))!= NULL) {
        for (i = 0; i < n_pvec; i++)                   /* Initialize mship */
            for (j = 0; j < cmodel->strct->n_class; j++)
                pvec->mship[i][j] = cmodel->strct->class_weight[j];

        if (structure) {                           /* Structure membership */
            for (i = 0; i < n_pvec; i++) {         /* for every fragment...*/
                fragment = getFragment (i, cmodel->n_att, structure);
                if (computeMembershipStrct(pvec->mship[i], fragment,
                                           cmodel->strct) == NULL) {
                    prob_vec_destroy (pvec);
                    return NULL;
                }
            }
            free_if_not_null (fragment);
        }

        if (sp || seq) {                /* Sequence or profile membership */
            aa_prob = f_matrix (n_pvec,  cmodel->strct->n_class);
            aa_class = E_MALLOC (sizeof (struct aa_clssfcn));
            aa_class->n_class = cmodel->strct->n_class;
            aa_class->n_att = cmodel->n_att;
            aa_class->log_pp = cmodel->log_pp;
            aa_class->class_wt = cmodel->strct->class_weight;
            if (seq){
                struct seq *s = seq_copy (seq);
                if (computeMembershipAA (aa_prob, s, aa_class)
                    == EXIT_FAILURE) {
                    prob_vec_destroy (pvec);
                    return NULL;
                }
                seq_destroy (s);
            } else if (sp) {
                if (computeMembershipAAProf (aa_prob, sp, aa_class)
                    == EXIT_FAILURE) {
                    prob_vec_destroy (pvec);
                    return NULL;
                }
            }
            free (aa_class);
            for (i = 0; i < n_pvec; i++)
                for (j = 0; j < cmodel->strct->n_class; j++)
                    pvec->mship[i][j] *= aa_prob[i][j];
            kill_f_matrix (aa_prob);
        }
        if (norm == YES) {
            for (i = 0; i < n_pvec; i++){
                double sum = 0.0;
                for (j = 0; j < cmodel->strct->n_class; j++)
                    sum += pvec->mship[i][j];
                for (j = 0; j < cmodel->strct->n_class; j++)
                    pvec->mship[i][j] /= sum;
            }
            pvec->norm_type = PVEC_TRUE_PROB;
        }
    }


    /*shoffmann*/
	compnd_len = structure->compnd_len;
    /*finally read compound*/ 
    if(compnd_len > 0){
    	pvec->compnd = E_MALLOC(compnd_len*sizeof(char));
	pvec->compnd = memmove(pvec->compnd, structure->compnd, compnd_len);
    }
    pvec->compnd_len = compnd_len;
    return pvec;		 

}