Skip to content

Commit

Permalink
normalize sequences to upper case
Browse files Browse the repository at this point in the history
  • Loading branch information
horta committed Feb 9, 2024
1 parent c93faa9 commit 20de076
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions c-core/sequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@
#include "error.h"
#include "imm/abc.h"
#include "xstrdup.h"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>

int sequence_init(struct sequence *x, struct imm_code const *code, long id,
char const *name, char const *data)
{
char *new_data = xstrdup(data);
if (!new_data) return error(DCP_ENOMEM);
for (size_t i = 0; i < strlen(new_data); ++i)
new_data[i] = toupper(new_data[i]);

int rc = 0;
x->id = id;
x->name = xstrdup(name);
x->data = xstrdup(data);
x->data = new_data;
imm_eseq_init(&x->imm.eseq, code);

if (!x->name || !x->data) defer_return(error(DCP_ENOMEM));

int abc = imm_eseq_abc(&x->imm.eseq)->typeid;
if (abc != IMM_DNA && abc == IMM_RNA) defer_return(error(DCP_ESEQABC));
if (abc != IMM_DNA && abc != IMM_RNA) defer_return(error(DCP_ESEQABC));

char *tmp = (char *)x->data;
if (abc == IMM_DNA) disambiguate_dna(strlen(tmp), tmp);
Expand Down

0 comments on commit 20de076

Please sign in to comment.