Skip to content

SamBuilder.add_single() cannot create a record without sequence or base qualities #211

@msto

Description

@msto

Summary

When attempting to construct a test record with no query sequence or qualities, I found that SamBuilder.add_single() constructs a record with the default base/quality values instead of a record with None in these attributes.

In [1]: from fgpyo.sam.builder import SamBuilder

In [2]: builder = SamBuilder()

In [3]: record = builder.add_single(bases=None, quals=None)

In [4]: record.query_sequence
Out[4]: 'AGGGCGACCTTCGATTCGGATGTGACATTTCATTACATTACGCTCAGGACTGCGAACGAAAGATTAAGAATGCTTAACCCGGTACCTAACCCATCTGATT'

In [5]: record.query_qualities
Out[5]: array('B', [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30])

Suggested solution

I think this originates from using None as a sentinel value for "use the defaults" in this method.

Instead, we could:

  • Change the default value for these parameters to the actual default query sequence and qualities, rather than None
  • When None is specified as a value for these parameters, return a record where query_sequence and query_qualities are None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions