Mercurial > repos > estrain > microrunqc
view microrunqc/median_size.py @ 24:dc12d6ac296d draft
Fixed bug in MLST ouput
author | estrain |
---|---|
date | Fri, 02 Feb 2024 15:16:46 +0000 |
parents | 2dc1074c9a6b |
children |
line wrap: on
line source
#!/usr/bin/env ## Errol Strain (estrain@gmail.com) ## calculate median insert size from sam file import numpy as np def get_data(infile): lengths = [] for line in infile: if line.startswith('@'): pass else: line = line.rsplit() length = int(line[8]) if length > 0: lengths.append(length) else: pass return lengths if __name__ == "__main__": import sys lengths = get_data(sys.stdin) md = int(np.median(lengths)) print(md)