Skip to content

Commit

Permalink
r98: force trimfq to output FASTQ
Browse files Browse the repository at this point in the history
  • Loading branch information
lh3 committed Feb 11, 2017
1 parent 281537b commit ce974f9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions seqtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,15 @@ int stk_trimfq(int argc, char *argv[])
gzFile fp;
kseq_t *seq;
double param = 0.05, q_int2real[128];
int i, c, min_len = 30, left = 0, right = 0, fixed_len = -1;
while ((c = getopt(argc, argv, "l:q:b:e:L:")) >= 0) {
int i, c, min_len = 30, left = 0, right = 0, fixed_len = -1, force_fq = 0;
while ((c = getopt(argc, argv, "l:q:b:e:L:Q")) >= 0) {
switch (c) {
case 'q': param = atof(optarg); break;
case 'l': min_len = atoi(optarg); break;
case 'b': left = atoi(optarg); break;
case 'e': right = atoi(optarg); break;
case 'L': fixed_len = atoi(optarg); break;
case 'Q': force_fq = 1; break;
}
}
if (optind == argc) {
Expand All @@ -299,6 +300,7 @@ int stk_trimfq(int argc, char *argv[])
fprintf(stderr, " -b INT trim INT bp from left (non-zero to disable -q/-l) [0]\n");
fprintf(stderr, " -e INT trim INT bp from right (non-zero to disable -q/-l) [0]\n");
fprintf(stderr, " -L INT retain at most INT bp from the 5'-end (non-zero to disable -q/-l) [0]\n");
fprintf(stderr, " -Q force FASTQ output\n");
fprintf(stderr, "\n");
return 1;
}
Expand Down Expand Up @@ -341,12 +343,12 @@ int stk_trimfq(int argc, char *argv[])
end = beg + min_len;
}
} else beg = 0, end = seq->seq.l;
putchar(seq->qual.l? '@' : '>'); fputs(seq->name.s, stdout);
putchar(force_fq || seq->qual.l? '@' : '>'); fputs(seq->name.s, stdout);
if (seq->comment.l) {
putchar(' '); puts(seq->comment.s);
} else putchar('\n');
fwrite(seq->seq.s + beg, 1, end - beg, stdout); putchar('\n');
if (seq->qual.l) {
if (force_fq || seq->qual.l) {
puts("+");
fwrite(seq->qual.s + beg, 1, end - beg, stdout); putchar('\n');
}
Expand Down Expand Up @@ -1663,7 +1665,7 @@ static int usage()
{
fprintf(stderr, "\n");
fprintf(stderr, "Usage: seqtk <command> <arguments>\n");
fprintf(stderr, "Version: 1.2-r95-dirty\n\n");
fprintf(stderr, "Version: 1.2-r98-dirty\n\n");
fprintf(stderr, "Command: seq common transformation of FASTA/Q\n");
fprintf(stderr, " comp get the nucleotide composition of FASTA/Q\n");
fprintf(stderr, " sample subsample sequences\n");
Expand Down

0 comments on commit ce974f9

Please sign in to comment.