Is your feature request related to a problem? Please specify.
From how I understand samtools split to work, it will create a new output file for each of the "splits" it encounters which may result in more open file handles than the system will allow. I suspect the --max-split NUM flag was added to manage this situation more carefully. I would like to split a BAM file by tag in which that tag has very high cardinality and I don't want to be limited by tool or system limits.
Describe the solution you would like.
My ideal solution is to collate/sort the BAM file by that tag (samtools sort -t TAG) then create the splits using samtools split -d TAG.
Could there be a way to tell samtools split the BAM is sorted/ordered so that file handles can be closed as the next one is opened and I don't need to worry about definiing --max-split nor raising/changing system limits?
Perhaps this could work without adding a new CLI flag if the header could describe the file as being grouped/sorted by the tag? I don't think that's currently possible since samtools sort by tag doesn't encode that information in the SO or GO of the header even though I wish it did. If a CLI flag is necessary, then maybe an --assume-ordered which would trigger this behavior and turn "off" --max-splits?
Is your feature request related to a problem? Please specify.
From how I understand
samtools splitto work, it will create a new output file for each of the "splits" it encounters which may result in more open file handles than the system will allow. I suspect the--max-split NUMflag was added to manage this situation more carefully. I would like to split a BAM file by tag in which that tag has very high cardinality and I don't want to be limited by tool or system limits.Describe the solution you would like.
My ideal solution is to collate/sort the BAM file by that tag (
samtools sort -t TAG) then create the splits usingsamtools split -d TAG.Could there be a way to tell
samtools splitthe BAM is sorted/ordered so that file handles can be closed as the next one is opened and I don't need to worry about definiing--max-splitnor raising/changing system limits?Perhaps this could work without adding a new CLI flag if the header could describe the file as being grouped/sorted by the tag? I don't think that's currently possible since
samtools sortby tag doesn't encode that information in theSOorGOof the header even though I wish it did. If a CLI flag is necessary, then maybe an--assume-orderedwhich would trigger this behavior and turn "off"--max-splits?