deps/kb_meme/meme-5.0.1/src/motif-in-meme-json.c
/*****************************************************************************
 * Define the structure of the JSON document
 ****************************************************************************/
Define the structure of the JSON document
Define the structure of the JSON document
JSON_OBJ_DEF_T *json_def(bool scan) {
  JsonSetupFn sseq_select, ssite_add, sseq_create, sseqs_create;
  JsonPropStringFn sseq_name;
  JsonPropNumberFn sseq_pv, ssite_motif, ssite_pos, ssite_pv, sseq_length;
  JsonPropBoolFn ssite_rc;
  JsonPropListFn scan_ready;
  if (scan) {
    sseqs_create = mhtml2_sseqs_create;
    sseq_create = mhtml2_sseq_create;
    sseq_name = mhtml2_sseq_name;
    sseq_length = mhtml2_sseq_length;
    sseq_select = mhtml2_sseq_select;
    sseq_pv = mhtml2_sseq_pv;
    ssite_add = mhtml2_ssite_add;
    ssite_motif = mhtml2_ssite_motif;
    ssite_pos = mhtml2_ssite_pos;
    ssite_rc = mhtml2_ssite_rc;
    ssite_pv = mhtml2_ssite_pv;
    scan_ready = mhtml2_scan_ready;
  } else {
    sseqs_create = NULL;
    sseq_create = NULL; sseq_name = NULL; sseq_length = NULL;
    sseq_select = NULL; sseq_pv = NULL; ssite_add = NULL;
    ssite_motif = NULL; ssite_pos = NULL; ssite_rc = NULL; ssite_pv = NULL;
    scan_ready = NULL;
  }
  return 
    jd_obj(NULL, NULL, NULL, true, 10,
      jd_pstr("program", true, mhtml2_program),
      jd_pstr("version", true, mhtml2_version),
      jd_pstr("release", true, mhtml2_release),
      jd_plst("cmd", true, NULL, 
        jd_lstr(1, NULL, NULL, NULL, NULL)
      ),
      jd_pobj("options", true, NULL, 
        jd_obj(NULL, NULL, NULL, true, 1, 
          jd_pbool("revcomp", false, mhtml2_alph_revcomp)
        )
      ),
      jd_pobj("alphabet", true, NULL,
        jd_obj(NULL, NULL, NULL, false, 6,
          jd_pstr("name", false, mhtml2_alph_name),
          jd_pstr("like", false, mhtml2_alph_extends),
          jd_pnum("ncore", false, mhtml2_alph_ncore),
          jd_pcust("symbols", true, JSON_STRING | JSON_LIST, mhtml2_alph_symbols,
            mhtml2_alph_symbols2, 
            jd_lobj(1, mhtml2_alph_start, mhtml2_alph_end, mhtml2_alph_abort, mhtml2_alph_entry,
              jd_obj(mhtml2_alph_sym_reset, NULL, NULL, false, 6,
                jd_pstr("symbol", true, mhtml2_alph_sym_symbol),
                jd_pstr("name", false, mhtml2_alph_sym_name),
                jd_pstr("colour", false, mhtml2_alph_sym_colour),
                jd_pstr("complement", false, mhtml2_alph_sym_complement),
                jd_pstr("equals", false, mhtml2_alph_sym_equals),
                jd_pstr("aliases", false, mhtml2_alph_sym_aliases)
              )
            )  
          ),
          jd_pstr("strands", false, mhtml2_alph_strands), 
          jd_plst("freqs", false, mhtml2_bgfreqs, 
            jd_lnum(1, mhtml2_freqs_create, mhtml2_freqs_finalize, mhtml2_freqs_abort, mhtml2_freqs_set)
          )
        )
      ),
      jd_pobj("background", false, NULL,
        jd_obj(NULL, NULL, NULL, false, 3,
          jd_pstr("source", false, NULL),
          jd_pnum("order", false, NULL),	
          jd_plst("freqs", true, mhtml2_bgfreqs,
            jd_lnum(1, mhtml2_freqs_create, mhtml2_freqs_finalize, mhtml2_freqs_abort, mhtml2_freqs_set)
          )
        )
      ),
      jd_pobj("sequence_db", true, NULL,
        jd_obj(NULL, NULL, NULL, true, 1,
          jd_plst("sequences", false, NULL,
            jd_lobj(1, sseqs_create, NULL, NULL, NULL,
              jd_obj(sseq_create, NULL, NULL, false, 3,
                jd_pstr("name", true, sseq_name),
                jd_pnum("length", true, sseq_length),
                jd_pnum("weight", true, NULL)
              )
            )
          )
        )
      ),  
      jd_plst("motifs", true, NULL,
        jd_lobj(1, NULL, NULL, NULL, mhtml2_motif_set,
          jd_obj(mhtml2_motif_create, mhtml2_motif_finalize, mhtml2_motif_abort, true, 9,
            jd_pnum("db", true, NULL),
            jd_pstr("id", true, mhtml2_motif_id),
            jd_pstr("alt", true, mhtml2_motif_alt),
            jd_pnum("len", true, mhtml2_motif_len),
            jd_pnum("nsites", true, mhtml2_motif_nsites),
            jd_pstr("evalue", true, mhtml2_motif_evalue),
            jd_pnum("ic", false, mhtml2_motif_ic),
            jd_plst("psm", false, mhtml2_psm_set,
              jd_lnum(2, mhtml2_matrix_setup, mhtml2_matrix_finalize, mhtml2_matrix_abort, mhtml2_matrix_set)
            ),
            jd_plst("pwm", true, mhtml2_pwm_set,
              jd_lnum(2, mhtml2_matrix_setup, mhtml2_matrix_finalize, mhtml2_matrix_abort, mhtml2_matrix_set)
            )
          )
        )
      ),
      jd_plst("scan", false, scan_ready,
        jd_lobj(1, NULL, NULL, NULL, NULL,
          jd_obj(sseq_select, NULL, NULL, true, 2,
            jd_pnum("pvalue", true, sseq_pv),
            jd_plst("sites", true, NULL,
              jd_lobj(1, NULL, NULL, NULL, NULL,
                jd_obj(ssite_add, NULL, NULL, true, 4,
                  jd_pnum("motif", true, ssite_motif),
                  jd_pnum("pos", true, ssite_pos),
                  jd_pbool("rc", true, ssite_rc),
                  jd_pnum("pvalue", true, ssite_pv)
                )
              )
            )
          )
        )
      )
    );
}
JSON_OBJ_DEF_T * json_def ( bool scan ) { JsonSetupFn sseq_select , ssite_add , sseq_create , sseqs_create ; JsonPropStringFn sseq_name ; JsonPropNumberFn sseq_pv , ssite_motif , ssite_pos , ssite_pv , sseq_length ; JsonPropBoolFn ssite_rc ; JsonPropListFn scan_ready ; if ( scan ) { sseqs_create = mhtml2_sseqs_create ; sseq_create = mhtml2_sseq_create ; sseq_name = mhtml2_sseq_name ; sseq_length = mhtml2_sseq_length ; sseq_select = mhtml2_sseq_select ; sseq_pv = mhtml2_sseq_pv ; ssite_add = mhtml2_ssite_add ; ssite_motif = mhtml2_ssite_motif ; ssite_pos = mhtml2_ssite_pos ; ssite_rc = mhtml2_ssite_rc ; ssite_pv = mhtml2_ssite_pv ; scan_ready = mhtml2_scan_ready ; } else { sseqs_create = NULL ; sseq_create = NULL ; sseq_name = NULL ; sseq_length = NULL ; sseq_select = NULL ; sseq_pv = NULL ; ssite_add = NULL ; ssite_motif = NULL ; ssite_pos = NULL ; ssite_rc = NULL ; ssite_pv = NULL ; scan_ready = NULL ; } return jd_obj ( NULL , NULL , NULL , true , 10 , jd_pstr ( " " , true , mhtml2_program ) , jd_pstr ( " " , true , mhtml2_version ) , jd_pstr ( " " , true , mhtml2_release ) , jd_plst ( " " , true , NULL , jd_lstr ( 1 , NULL , NULL , NULL , NULL ) ) , jd_pobj ( " " , true , NULL , jd_obj ( NULL , NULL , NULL , true , 1 , jd_pbool ( " " , false , mhtml2_alph_revcomp ) ) ) , jd_pobj ( " " , true , NULL , jd_obj ( NULL , NULL , NULL , false , 6 , jd_pstr ( " " , false , mhtml2_alph_name ) , jd_pstr ( " " , false , mhtml2_alph_extends ) , jd_pnum ( " " , false , mhtml2_alph_ncore ) , jd_pcust ( " " , true , JSON_STRING | JSON_LIST , mhtml2_alph_symbols , mhtml2_alph_symbols2 , jd_lobj ( 1 , mhtml2_alph_start , mhtml2_alph_end , mhtml2_alph_abort , mhtml2_alph_entry , jd_obj ( mhtml2_alph_sym_reset , NULL , NULL , false , 6 , jd_pstr ( " " , true , mhtml2_alph_sym_symbol ) , jd_pstr ( " " , false , mhtml2_alph_sym_name ) , jd_pstr ( " " , false , mhtml2_alph_sym_colour ) , jd_pstr ( " " , false , mhtml2_alph_sym_complement ) , jd_pstr ( " " , false , mhtml2_alph_sym_equals ) , jd_pstr ( " " , false , mhtml2_alph_sym_aliases ) ) ) ) , jd_pstr ( " " , false , mhtml2_alph_strands ) , jd_plst ( " " , false , mhtml2_bgfreqs , jd_lnum ( 1 , mhtml2_freqs_create , mhtml2_freqs_finalize , mhtml2_freqs_abort , mhtml2_freqs_set ) ) ) ) , jd_pobj ( " " , false , NULL , jd_obj ( NULL , NULL , NULL , false , 3 , jd_pstr ( " " , false , NULL ) , jd_pnum ( " " , false , NULL ) , jd_plst ( " " , true , mhtml2_bgfreqs , jd_lnum ( 1 , mhtml2_freqs_create , mhtml2_freqs_finalize , mhtml2_freqs_abort , mhtml2_freqs_set ) ) ) ) , jd_pobj ( " " , true , NULL , jd_obj ( NULL , NULL , NULL , true , 1 , jd_plst ( " " , false , NULL , jd_lobj ( 1 , sseqs_create , NULL , NULL , NULL , jd_obj ( sseq_create , NULL , NULL , false , 3 , jd_pstr ( " " , true , sseq_name ) , jd_pnum ( " " , true , sseq_length ) , jd_pnum ( " " , true , NULL ) ) ) ) ) ) , jd_plst ( " " , true , NULL , jd_lobj ( 1 , NULL , NULL , NULL , mhtml2_motif_set , jd_obj ( mhtml2_motif_create , mhtml2_motif_finalize , mhtml2_motif_abort , true , 9 , jd_pnum ( " " , true , NULL ) , jd_pstr ( " " , true , mhtml2_motif_id ) , jd_pstr ( " " , true , mhtml2_motif_alt ) , jd_pnum ( " " , true , mhtml2_motif_len ) , jd_pnum ( " " , true , mhtml2_motif_nsites ) , jd_pstr ( " " , true , mhtml2_motif_evalue ) , jd_pnum ( " " , false , mhtml2_motif_ic ) , jd_plst ( " " , false , mhtml2_psm_set , jd_lnum ( 2 , mhtml2_matrix_setup , mhtml2_matrix_finalize , mhtml2_matrix_abort , mhtml2_matrix_set ) ) , jd_plst ( " " , true , mhtml2_pwm_set , jd_lnum ( 2 , mhtml2_matrix_setup , mhtml2_matrix_finalize , mhtml2_matrix_abort , mhtml2_matrix_set ) ) ) ) ) , jd_plst ( " " , false , scan_ready , jd_lobj ( 1 , NULL , NULL , NULL , NULL , jd_obj ( sseq_select , NULL , NULL , true , 2 , jd_pnum ( " " , true , sseq_pv ) , jd_plst ( " " , true , NULL , jd_lobj ( 1 , NULL , NULL , NULL , NULL , jd_obj ( ssite_add , NULL , NULL , true , 4 , jd_pnum ( " " , true , ssite_motif ) , jd_pnum ( " " , true , ssite_pos ) , jd_pbool ( " " , true , ssite_rc ) , jd_pnum ( " " , true , ssite_pv ) ) ) ) ) ) ) ) ; }
Define the structure of the JSON document
Define the structure of the JSON document
// there are lots of other options but they're not important for reading motifs // originally the symbols were just a string with all the core symbols // of the alphabet but with the addition of custom alphabets it was // changed to a list of objects // removed, now served by combination of alphabet and revcomp // moved outsize alphabet and turned into object // not present in old format 4-Aug-2017