Created
May 9, 2024 20:04
-
-
Save brantfaircloth/acd5dc19b3b65c716f132b510a914ea7 to your computer and use it in GitHub Desktop.
Contig coverage from PB.cov
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
Created by Brant Faircloth on May 9, 2024 at 14:00:38 CDT | |
Copyright (c) 2024 Brant C. Faircloth. All rights reserved. | |
Description: | |
""" | |
#import pdb | |
import numpy | |
from collections import defaultdict | |
values = defaultdict(list) | |
with open("PB.base.cov") as infile: | |
for line in infile: | |
ls = line.strip() | |
if line.startswith(">"): | |
curr_contig = line.lstrip(">").split("\t")[0] | |
else: | |
cov =ls.split("\t")[2] | |
values[curr_contig].append(int(cov)) | |
for k,v in values.items(): | |
print(k,numpy.mean(v)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment