INNER CODE UNIT · Python
_each
open2c/bioframe · src/bioframe/extras.py:253
def _each(bin):
s = str(fasta_records[bin.chrom][bin.start : bin.end])
nbases = len(s)
n = s.count("N")
n += s.count("n")
return (nbases - n) / nbases if nbases > 0 else 0
if return_input:
return pd.concat(
[df, df.apply(_each, axis=1).rename("frac_mapped", inplace=True)],
axis="columns",
)
else:
return df.apply(_each, axis=1).rename("frac_mapped", inplace=True)
def frac_gc(df, fasta_records, mapped_only=True, return_input=True):
"""