Skip to content

Commit

Permalink
Tolerate extra (12th) field in SAM input
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Bacon committed Mar 8, 2020
1 parent 85d1c78 commit fd53504
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ad2vcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ int sam_read_alignment(const char *argv[],
char pos_str[SAM_POS_MAX_DIGITS + 1],
*end;
size_t len;
static size_t previous_pos = 0;

if ( tsv_read_field(argv, sam_stream, sam_alignment->qname, SAM_QNAME_MAX, &len) != EOF )
{
Expand All @@ -349,8 +350,12 @@ int sam_read_alignment(const char *argv[],
{
fprintf(stderr, "%s: Invalid alignment position: %s\n",
argv[0], pos_str);
fprintf(stderr, "qname = %s rname = %s\n",
sam_alignment->qname, sam_alignment->rname);
fprintf(stderr, "previous_pos = %zu\n", previous_pos);
exit(EX_DATAERR);
}
previous_pos = sam_alignment->pos;

// MAPQ
tsv_skip_field(argv, sam_stream);
Expand All @@ -372,7 +377,10 @@ int sam_read_alignment(const char *argv[],
&sam_alignment->seq_len);

// QUAL
tsv_skip_field(argv, sam_stream);
// Some SRA CRAMs have 11 fields, most have 12
if ( tsv_skip_field(argv, sam_stream) == '\t' )
while ( getc(sam_stream) != '\n' )
;
return 1;
}
else
Expand Down

0 comments on commit fd53504

Please sign in to comment.