I am trying to filter a bam file. I mapped raw nanopore reads to a reference assembly and want to keep only reads that map (almost) full length. bwa mem and minimap2 softmask bases at both ends that do not match to the reference and I want to keep only those reads that map full-length and allowing for 40bp unmatched/softmasked bp on both ends. Tried Samclip, but it does not work (outputting text file instead of true sam file). Any ideas on how to filter otherwise?