You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've written something along the lines of the following for a couple client projects, and think it would be sensible to have this functionality available in fgpyo.
Ideally the syntax would parallel pysam's, e.g. writer.write(template), but I don't think this is possible without monkey patching AlignmentFile. Is there a preference between implementing this as a standalone function, a la below, or as a method on Template?
defwrite_template(
template: Template,
writer: AlignmentFile,
primary_only: bool=False,
) ->None:
"""Write the records associated with a Template to file. Args: template: The Template to write. writer: An open, writable AlignmentFile. primary_only: If True, only write primary alignments. """ifprimary_only:
rec_iter=template.primary_recs()
else:
rec_iter=template.all_recs()
forrecinrec_iter:
writer.write(rec)
The text was updated successfully, but these errors were encountered:
I agree this would be nice. I think I would prefer it as a function on Template, perhaps called def write_to(self, writer: AlignmentFile, ...). I think if it's an independent function it will be harder to find/discover.
I've written something along the lines of the following for a couple client projects, and think it would be sensible to have this functionality available in
fgpyo
.Ideally the syntax would parallel pysam's, e.g.
writer.write(template)
, but I don't think this is possible without monkey patchingAlignmentFile
. Is there a preference between implementing this as a standalone function, a la below, or as a method onTemplate
?The text was updated successfully, but these errors were encountered: