Skip to content

Commit

Permalink
version with protection in out symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
pratas committed Oct 28, 2024
1 parent fc861b8 commit 6bc1ebe
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
34 changes: 29 additions & 5 deletions src/Jarvis3.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ int FindDataType(char *FN)
return type;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// ERR AND EXIT ON UNKNOWN SYMBOL
//
void ErrAndExit(void)
{
fprintf(stderr, "Error: non ACGT symbol in sequence!\n");
exit(1);
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// ENCODE HEADER RMS ONLY
//
Expand Down Expand Up @@ -254,8 +263,13 @@ void CompressRMsOnly(PARAM *P, char *fn)

while((m = fread(t, sizeof(uint8_t), NSYM, IN)) == NSYM)
{
if(!strchr("ACGT", t[0])) ErrAndExit();
if(!strchr("ACGT", t[1])) ErrAndExit();
if(!strchr("ACGT", t[2])) ErrAndExit();
if(!strchr("ACGT", t[3])) ErrAndExit();

buf[i] = S2N(t[3])|(S2N(t[2])<<2)|(S2N(t[1])<<4)|(S2N(t[0])<<6); // PACK 4

for(n = 0 ; n < m ; ++n)
{
SB->buf[SB->idx] = sym = S2N(t[n]);
Expand Down Expand Up @@ -405,10 +419,15 @@ void CompressNoNN(PARAM *P, char *fn)

while((m = fread(t, sizeof(uint8_t), NSYM, IN)) == NSYM)
{
if(!strchr("ACGT", t[0])) ErrAndExit();
if(!strchr("ACGT", t[1])) ErrAndExit();
if(!strchr("ACGT", t[2])) ErrAndExit();
if(!strchr("ACGT", t[3])) ErrAndExit();

buf[i] = S2N(t[3])|(S2N(t[2])<<2)|(S2N(t[1])<<4)|(S2N(t[0])<<6); // PACK 4

for(n = 0 ; n < m ; ++n){

for(n = 0 ; n < m ; ++n)
{
SB->buf[SB->idx] = sym = S2N(t[n]);

memset((void *)PT->freqs, 0, NSYM * sizeof(double));
Expand Down Expand Up @@ -629,10 +648,15 @@ void Compress(PARAM *P, char *fn){

while((m = fread(t, sizeof(uint8_t), NSYM, IN)) == NSYM)
{
buf[i] = S2N(t[3])|(S2N(t[2])<<2)|(S2N(t[1])<<4)|(S2N(t[0])<<6); // PACK 4
if(!strchr("ACGT", t[0])) ErrAndExit();
if(!strchr("ACGT", t[1])) ErrAndExit();
if(!strchr("ACGT", t[2])) ErrAndExit();
if(!strchr("ACGT", t[3])) ErrAndExit();

for(n = 0 ; n < m ; ++n){
buf[i] = S2N(t[3])|(S2N(t[2])<<2)|(S2N(t[1])<<4)|(S2N(t[0])<<6); // PACK 4

for(n = 0 ; n < m ; ++n)
{
SB->buf[SB->idx] = sym = S2N(t[n]);

memset((void *)PT->freqs, 0, NSYM * sizeof(double));
Expand Down
2 changes: 1 addition & 1 deletion src/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ PARAM;

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

#define RELEASE 6
#define RELEASE 7
#define VERSION 3

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down

0 comments on commit 6bc1ebe

Please sign in to comment.