⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alnread.c

📁 ncbi源码
💻 C
📖 第 1 页 / 共 5 页
字号:
}/* This function creates and sends an error message indicating that the * most common length of the sequences in the file do not match a comment * found in the file. */static void s_ReportBadSequenceLength (char *               id, int                  expected_length, int                  actual_length, FReportErrorFunction report_error, void *               report_error_userdata){    TErrorInfoPtr eip;    const char *  format_str = "Expected sequence length %d, actual length %d";    if (report_error == NULL) {        return;    }    eip = ErrorInfoNew (NULL);    if (eip == NULL) {        return;    }    eip->category = eAlnErr_BadFormat;    eip->id = strdup (id);    eip->message = malloc (strlen (format_str) + 50);    if (eip->message != NULL) {        sprintf (eip->message, format_str, expected_length, actual_length);    }    report_error (eip, report_error_userdata);}/* This function creates and sends an error message indicating that the * number of sequences read does not match a comment in the alignment file. */static voids_ReportIncorrectNumberOfSequences(int                  num_expected, int                  num_found, FReportErrorFunction report_error, void *              report_error_userdata){    TErrorInfoPtr eip;    const char *  err_format = "Expected %d sequences, found %d";     if (report_error == NULL) {        return;    }    eip = ErrorInfoNew (NULL);    if (eip == NULL) {        return;    }    eip->category = eAlnErr_BadFormat;    eip->message = (char *) malloc (strlen (err_format) +                                    2 * kMaxPrintedIntLen + 1);                                         if (eip->message != NULL)    {        sprintf (eip->message, err_format, num_expected, num_found);    }    report_error (eip, report_error_userdata);}static voids_ReportIncorrectSequenceLength (int                 len_expected, int                 len_found, FReportErrorFunction report_error, void *             report_error_userdata){    TErrorInfoPtr eip;    const char *  err_format = "Expected sequences of length %d, found %d";    if (report_error == NULL) {        return;    }    eip = ErrorInfoNew (NULL);    if (eip == NULL) {        return;    }    eip->category = eAlnErr_BadFormat;    eip->message = (char *)malloc (strlen (err_format)                                   + 2 * kMaxPrintedIntLen + 1);    if (eip->message != NULL)    {      sprintf (eip->message, err_format, len_expected, len_found);    }    report_error (eip, report_error_userdata);}/* This function creates and sends an error message regarding a non-unique * organism name. */static voids_ReportRepeatedOrganismName(char *               id, int                  line_num, int                  second_line_num, char *               org_name, FReportErrorFunction report_error, void *              report_error_userdata){    TErrorInfoPtr eip;    const char *  err_format = "Organism name %s also appears at line %d";    if (report_error == NULL || org_name == NULL) {        return;    }    eip = ErrorInfoNew (NULL);    if (eip == NULL) {        return;    }    eip->category = eAlnErr_BadData;    eip->line_num = line_num;    if (id != NULL ) {        eip->id = strdup (id);    }    eip->message = malloc (strlen (err_format) + strlen (org_name)                           + kMaxPrintedIntLen + 1);    if (eip->message != NULL) {        sprintf (eip->message, err_format, org_name, second_line_num);    }    report_error (eip, report_error_userdata);}/* This function creates and sends an error message indicating that some or * all of the organism information for the sequences are missing. */static voids_ReportMissingOrganismInfo(FReportErrorFunction report_error, void *             report_error_userdata){    TErrorInfoPtr eip;    if (report_error == NULL) {        return;    }    eip = ErrorInfoNew (NULL);    if (eip == NULL) {        return;    }    eip->category = eAlnErr_BadData;    eip->message = strdup ("Missing organism information");    report_error (eip, report_error_userdata);}/* This function creates and sends an error message regarding an ID that is * used for more than one sequence. */static void s_ReportRepeatedId (TStringCountPtr      scp, FReportErrorFunction report_error, void *              report_error_userdata){    TErrorInfoPtr  eip;    const char *   err_format = "ID %s appears in the following locations:";    char *         cp;    TIntLinkPtr    line_number;    if (report_error == NULL  ||  scp == NULL  ||  scp->string == NULL) {        return;    }    eip = ErrorInfoNew (NULL);    if (eip == NULL) {        return;    }    eip->category = eAlnErr_BadData;    eip->id = strdup (scp->string);    if (scp->line_numbers != NULL) {        eip->line_num = scp->line_numbers->ival;    }    eip->message = (char *) malloc ( strlen (err_format)                                    + strlen (scp->string)                                    + scp->num_appearances * 15                                    + 1);    if (eip->message != NULL) {        sprintf (eip->message, err_format, scp->string);        cp = eip->message + strlen (eip->message);        for (line_number = scp->line_numbers;             line_number != NULL;             line_number = line_number->next) {            sprintf (cp, " %d", line_number->ival);            cp += strlen (cp);        }    }    report_error (eip, report_error_userdata);}/* This function creates and sends an error message indicating that the file * being read is an ASN.1 file. */static void s_ReportASN1Error (FReportErrorFunction errfunc, void *             errdata){    TErrorInfoPtr eip;    const char * msg = "This is an ASN.1 file, "        "which cannot be read by this function.";    if (errfunc == NULL) {        return;    }    eip = ErrorInfoNew (NULL);    if (eip != NULL) {        eip->category = eAlnErr_BadData;        eip->message = (char *) malloc (strlen (msg) + 1);        if (eip->message != NULL) {            sprintf (eip->message, msg);        }        errfunc (eip, errdata);    }}/* This function reports that some sequences are inside brackets (indicating a segmented set) * and that some sequences are outside the brackets. */static void s_ReportSegmentedAlignmentError (TIntLinkPtr          offset_list, FReportErrorFunction errfunc, void *               errdata){    TErrorInfoPtr eip;    const char * msg = "This file contains sequences in brackets (indicating "        "a segmented alignment) as well as sequences not in brackets at lines "        "%s.  Please either add or remove brackets to correct this problem.";    int num_lines = 0;    int         msg_len = 0;    TIntLinkPtr t;    char *      line_text_list;    char *      line_text_list_offset;    if (errfunc == NULL || offset_list == NULL) {        return;    }    for (t = offset_list; t != NULL; t = t->next)    {        num_lines ++;    }    msg_len = num_lines * (kMaxPrintedIntLen + 2);    if (num_lines > 1)     {    	msg_len += 4;    }    line_text_list = (char *) malloc (msg_len);    if (line_text_list == NULL) return;    line_text_list_offset = line_text_list;    for (t = offset_list; t != NULL; t = t->next)    {        if (t->next == NULL)        {            sprintf (line_text_list_offset, "%d", t->ival);        }        else if (num_lines == 2)         {        	sprintf (line_text_list_offset, "%d and ", t->ival);        }        else if (t->next->next == NULL)        {        	sprintf (line_text_list_offset, "%d, and ", t->ival);        }        else        {        	sprintf (line_text_list_offset, "%d, ", t->ival);        }        line_text_list_offset += strlen (line_text_list_offset);    }    msg_len += strlen (msg) + 1;    eip = ErrorInfoNew (NULL);    if (eip != NULL) {        eip->category = eAlnErr_BadData;        eip->message = (char *) malloc (msg_len);        if (eip->message != NULL) {            sprintf (eip->message, msg, line_text_list);        }        errfunc (eip, errdata);    }    free (line_text_list);}/* This function reports an error if a line looks like it might contain an organism comment * but is somehow improperly formatted */static void s_ReportOrgCommentError (char *               linestring, FReportErrorFunction errfunc, void *               errdata){    TErrorInfoPtr eip;    const char * msg = "This line may contain an improperly formatted organism description.\n"                       "Organism descriptions should be of the form [org=tax name] or [organism=tax name].\n";        if (errfunc == NULL || linestring == NULL) {        return;    }                           eip = ErrorInfoNew (NULL);    if (eip != NULL) {        eip->category = eAlnErr_BadData;        eip->message = (char *) malloc (strlen (msg) + strlen (linestring) + 1);        if (eip->message != NULL) {            strcpy (eip->message, msg);            strcat (eip->message, linestring);        }        errfunc (eip, errdata);    }} /* This function reports that the number of segments in an alignment of * segmented sets is inconsistent. */static void s_ReportBadNumSegError (int                  line_num, int                  num_seg, int                  num_seg_exp, FReportErrorFunction errfunc, void *               errdata){    TErrorInfoPtr eip;    const char * msg = "This segmented set contains a different number of segments (%d) than expected (%d).\n";        if (errfunc == NULL) {        return;    }                           eip = ErrorInfoNew (NULL);    if (eip != NULL) {        eip->line_num = line_num;        eip->category = eAlnErr_BadData;        eip->message = (char *) malloc (strlen (msg) + 2 * kMaxPrintedIntLen + 1);        if (eip->message != NULL) {            sprintf (eip->message, msg, num_seg, num_seg_exp);        }        errfunc (eip, errdata);    }} /* This function allocates memory for a SSequenceInfo structure and * initializes the member variables.  It returns a pointer to the newly * allocated memory. */extern TSequenceInfoPtr SequenceInfoNew (void){    TSequenceInfoPtr sip;    sip = (TSequenceInfoPtr) malloc (sizeof (SSequenceInfo));    if (sip == NULL) {        return NULL;    }    sip->missing       = strdup ("?");    sip->beginning_gap = strdup (".");    sip->middle_gap    = strdup ("-");    sip->end_gap       = strdup (".");    sip->match         = strdup (".");    sip->alphabet      = NULL;    return sip;}/* This function frees memory associated with the member variables of * the SSequenceInfo structure and with the structure itself. */extern void SequenceInfoFree (TSequenceInfoPtr sip){    if (sip == NULL) {        return;    }    free (sip->alphabet);    free (sip->missing);    free (sip->beginning_gap);    free (sip->middle_gap);    free (sip->end_gap);    free (sip->match);    sip->alphabet = NULL;    free (sip);}/* This function creates and sends an error message regarding an unused line. */static void s_ReportUnusedLine(int                  line_num_start, int                  line_num_stop, TLineInfoPtr         line_val, FReportErrorFunction errfunc, void *               errdata){    TErrorInfoPtr eip;    const char * errformat1 = "Line %d could not be assigned to an interleaved block";    const char * errformat2 = "Lines %d through %d could not be assigned to an interleaved block";    const char * errformat3 = "Contents of unused line: %s";    int skip;    if (errfunc == NULL  ||  line_val == NULL) {        return;    }    eip = ErrorInfoNew (NULL);    if (eip != NULL) {        eip->category = eAlnErr_BadFormat;        eip->line_num = line_num_start;        if (line_num_start == line_num_stop) {              eip->message = (char *) malloc (strlen (errformat1)                                            + kMaxPrintedIntLen + 1);            if (eip->message != NULL) {                sprintf (eip->message, errformat1, line_num_start);            }        } else {            eip->message = (char *) malloc (strlen (errformat2)                                            + 2 * kMaxPrintedIntLen + 1);            if (eip->message != NULL) {                sprintf (eip->message, errformat2, line_num_start,                         line_num_stop);            }        }        errfunc (eip, errdata);    }    /* report contents of unused lines */    for (skip = line_num_start;         skip < line_num_stop + 1  &&  line_val != NULL;         skip++) {        if (line_val->data == NULL) {            continue;        }        eip = ErrorInfoNew (NULL);        if (eip != NULL) {            eip->category = eAlnErr_BadFormat;            eip->line_num = skip;            eip->message = (char *) malloc (strlen (errformat3)                                            + strlen (line_val->data) + 1);            if (eip->message != NULL) {                sprintf (eip->message, errformat3, line_val->data);            }            errfunc (eip, errdata);        }        line_val = line_val->next;    }}/* The following functions are used to manage a linked list of integer * values. *//* This function creates a new SIntLink structure with a value of ival.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -