Skip to content

Instantly share code, notes, and snippets.

@StephenFordham
Created July 7, 2024 13:34
Show Gist options
  • Save StephenFordham/eada3cf74d7d2c5200e22a3f4b66c7c1 to your computer and use it in GitHub Desktop.
Save StephenFordham/eada3cf74d7d2c5200e22a3f4b66c7c1 to your computer and use it in GitHub Desktop.
short_read_depth_calculation
def depth_calc(file, read_depth=0):
df = pd.read_csv(file, sep='\t', header=None)
df.columns = ['consensus', 'base_position', 'depth']
plasmid_length = df['base_position'].max()
base_coverage = df[df['depth'] > read_depth].__len__()
cov_perc = (base_coverage/plasmid_length) * 100
return cov_perc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment