Skip to content

Commit 1f09c60

Browse files
committed
rm nasty bug in weird fasta processing
1 parent af29e1b commit 1f09c60

File tree

3 files changed

+7
-34
lines changed

3 files changed

+7
-34
lines changed

bin/gto

0 Bytes
Binary file not shown.

bin/gto_fasta_rand_extra_chars

-4 KB
Binary file not shown.

src/FastaRandExtraChars.c

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -64,46 +64,19 @@ int main(int argc, char *argv[])
6464

6565
Buffer = CreateBuffer(BUF_SIZE);
6666

67+
uint8_t header = 0, sym;
6768
while((streamSize = fread(Buffer->buf, 1, Buffer->size, stdin)))
6869
{
6970
for(index = 0 ; index < streamSize ; ++index)
7071
{
71-
value = Buffer->buf[index];
72-
switch(line)
73-
{
74-
case 0:
75-
if(value == '\n')
76-
{
77-
line = 1;
78-
putchar(value);
79-
break;
80-
}
72+
sym = Buffer->buf[index];
8173

82-
if(position == 0 && value != '>')
83-
{
84-
RandIfExtra(value, bases);
85-
line = 1;
86-
break;
87-
}
74+
if(sym == '>'){ header = 1; putchar(sym); continue; }
75+
if(sym == '\n' && header == 1){ header = 0; putchar(sym); continue; }
76+
if(sym == '\n'){ putchar(sym); continue; }
77+
if(header == 1){ putchar(sym); continue; }
8878

89-
if(position++ == 0 && value == '>')
90-
{
91-
putchar(value);
92-
break;
93-
}
94-
putchar(value);
95-
break;
96-
case 1:
97-
if(value == '\n')
98-
{
99-
line = 0;
100-
position = 0;
101-
putchar(value);
102-
break;
103-
}
104-
RandIfExtra(value, bases);
105-
break;
106-
}
79+
RandIfExtra(sym, bases);
10780
}
10881
}
10982

0 commit comments

Comments
 (0)