#define PROG_NAME "dm_show_alignments" #define PROG_DESC "writes the nucleotide sequence alignments for a list of candidates" #define PROG_VERS "1.0" /* Last edited on 2024-12-21 14:04:20 by stolfi */ #define dm_show_alignments_C_COPYRIGHT \ "Copyright © 2013 by the State University of Campinas (UNICAMP)" \ " and the Federal Fluminense University (UFF)" /* !!! Fix the INFO and HELP !!! */ #define PROG_HELP \ PROG_NAME " \\\n" \ " [ -maxCands {MAX} ] \\\n" \ " -seqA {SEQA_TAG} {SEQA_FILE} \\\n" \ " -seqB {SEQB_TAG} {SEQB_FILE} \\\n" \ " -cands {CDV_FILE} \\\n" \ " " argparser_help_info_HELP " \\\n" #define PROG_INFO \ "NAME\n" \ " " PROG_NAME " - " PROG_DESC "\n" \ "\n" \ "SYNOPSIS\n" \ " " PROG_HELP "\n" \ "\n" \ "DESCRIPTION\n" \ " This program reads two nucleotide sequences and a list" \ " of candidate pairings between them, and prints the alignments" \ " of the two sequences described by those candidates.\n" \ "\n" \ " The input is assumed to be in {.cdv} format. ???\n" \ "\n" \ " The output file with the alignments is written to standard output" \ "\n" \ "OPTIONS\n" \ " -cands {CDV_FILE} \n" \ " Specifies the file name of the candidate list.\n" \ "\n" \ " -seqA {SEQA_TAG} {SEQA_FILE} \n" \ " -seqB {SEQB_TAG} {SEQB_FILE} \n" \ " Specifies the internal names (tags) of the two sequences paired by those" \ " candidates, and the corresponding file names.\n" \ "\n" \ argparser_help_info_HELP_INFO "\n" \ "SEE ALSO\n" \ " dm_cands_refine(1)\n" \ "\n" \ "AUTHOR AND HISTORY\n" \ " 2012-10: Created by R. Saracchini, as part of {dm_analyse_cdv.c}.\n" \ " 2013-05-05: Made into a separate program by J. Stolfi.\n" \ "\n" \ "WARRANTY\n" \ argparser_help_info_NO_WARRANTY "\n" \ "\n" \ "RIGHTS\n" \ " " dm_show_alignments_C_COPYRIGHT ".\n" \ "\n" \ argparser_help_info_STANDARD_RIGHTS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef struct options_t { char *cands; char *seqA_tag; char *seqA_file; char *seqB_tag; char *seqB_file; } options_t; options_t *dmsa_get_options(int argc, char**argv); int main(int argc,char** argv) { options_t* o = dmsa_get_options(argc,argv); /* Read the nucleic sequences: */ dnae_seq_t seqA = dnae_seq_read_from_nucleic_file_named(o->seqA_file, "", "", 0, o->seqA_tag, FALSE); dnae_seq_t seqB = dnae_seq_read_from_nucleic_file_named(o->seqB_file, "", "", 1, o->seqB_tag, FALSE); /* Read candidate file: */ FILE *rd = open_read(o->cands, TRUE); msm_cand_vec_t cdv = msm_cand_vec_read(rd); fclose(rd); int nc = cdv.ne; int i; for (i = 0; i < nc; i++) { msm_cand_t *cd = &(cdv.e[i]); demand(strcmp(cd->seq[0].name, seqA.sd.name) == 0, "wrong sequences for cand"); demand(strcmp(cd->seq[1].name, seqB.sd.name) == 0, "wrong sequences for cand"); dm_cand_write_with_alignment(stdout, cd, &seqA, &seqB); } fflush(stdout); msm_cand_vec_free(&cdv); return 0; } options_t *dmsa_get_options(int argc, char**argv) { options_t *o = (options_t *)notnull(malloc(sizeof(options_t)), "no mem"); argparser_t *pp = argparser_new(stderr, argc, argv); argparser_set_help(pp, PROG_HELP); argparser_set_info(pp, PROG_INFO); argparser_process_help_info_options(pp); argparser_get_keyword(pp,"-cands"); o->cands = argparser_get_next(pp); argparser_get_keyword(pp,"-seqA"); o->seqA_tag = argparser_get_next(pp); o->seqA_file = argparser_get_next(pp); argparser_get_keyword(pp,"-seqB"); o->seqB_tag = argparser_get_next(pp); o->seqB_file = argparser_get_next(pp); argparser_finish(pp); return o; }