broadinstitute / longbow

Annotation and segmentation of MAS-seq data
https://broadinstitute.github.io/longbow/
BSD 3-Clause "New" or "Revised" License
20 stars 4 forks source link

moved load_model to allow stream processing #203

Open jamestwebber opened 1 year ago

jamestwebber commented 1 year ago

This PR closes #199 (I hope). As described in the issue, various longbow commands were failing when reading from stdin. This PR changes load_model() to expect an open pysam.AlignmentFile rather than a stream or filename, and moves the call inside the with statement where the file is being read (which is almost always what happens immediately after loading a model from a BAM file).

This should be okay to do, as the model is stored in the header if at all, and so load_model will only consume the first piece of the stream and none of the reads.